SQL Server Query for pagination

I have SQL Server database and web application. I need pagination to view of records from DB same as Google. My query consists of 1000 records when I need to display page 2 I need records from 11-20. I want to fetch just these 10 records from the DB. I know I can query all 1000 records (this wastes time) and after that I can query the next 10 recordset. I need a better way to query the desired recordset - as an example when the user goes to page 5 (with 10 records per page) I need a query to get record 51-60 (just ten records) an this way is better for response time and network traffic.

best regards Hamidreza Abbasi

more ▼

asked Nov 09, 2009 at 11:16 AM in Default

avatar image

Hamidreza Abbasi
11 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Do the previous answers on pagination help?


more ▼

answered Nov 09, 2009 at 03:50 PM

avatar image

Kristen ♦
2.2k 7 11 14

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Nov 09, 2009 at 11:16 AM

Seen: 1721 times

Last Updated: Nov 09, 2009 at 03:48 PM

Copyright 2018 Redgate Software. Privacy Policy