Problem solve Get help with specific problems with your technologies, process and projects.

What's the best way to page SQL Server data results?

My question is regarding paging SQL Server data results. I am using PHP with SQL Server. For a specific search I have nearly 500 records. I am displaying 50 results per page and providing PREV and NEXT option for paging. In order to fetch the second set of results (for page 2), what I am doing is running the query again (fetching the whole 500 records) and just filtering the first 50 records inside the script and start displaying records from 50 to 100. I know this is not the best way to do it. Could you please suggest a better solution for this? Also, is it Ok to query the database for each page? At the same time, my query involves joins with 3 tables. Please help me on this.
I am not familiar with PHP but look into the record set options. I know with the latest build of ADO.NET, many options are available to cache the record set and only traverse the record sets that are needed and then query SQL Server for the needed data.

Dig Deeper on Microsoft SQL Server Performance Monitoring and Tuning

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.