x

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

Hamidreza Abbasi gravatar 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?

http://ask.sqlteam.com/questions/tagged/paging

more ▼

answered Nov 09, 2009 at 03:50 PM

Kristen gravatar image

Kristen ♦
2.2k 6 7 10

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

SQL Server Central

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

Topics:

x11

asked: Nov 09, 2009 at 11:16 AM

Seen: 1299 times

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