Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How can I do paging in Transact SQL?

Author  Topic 

Daniel Israel
Starting Member

15 Posts

Posted - 2007-04-20 : 16:55:11

I'm working on a front end where I want the user to be able get (huge amounts of) data in pages. I know I can get the TOP n records returned, but how to I get the NEXT n? Is there a way to do this?

Thanks for the help.

-D. Israel

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-04-20 : 16:57:55
Microsoft supports using the sqldatareader class and read each record.
Go to Top of Page

Daniel Israel
Starting Member

15 Posts

Posted - 2007-04-20 : 17:01:56
quote:
Originally posted by Vinnie881

Microsoft supports using the sqldatareader class and read each record.



so you're saying it can't be done?

-D. Israel
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-04-23 : 01:32:56
it can be done. have a look at Jeff's articles here: http://weblogs.sqlteam.com/jeffs/category/162.aspx


www.elsasoft.org
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-04-23 : 01:44:34
For SQL 2005 see also: http://www.sqlteam.com/item.asp?ItemID=26455
Go to Top of Page

Daniel Israel
Starting Member

15 Posts

Posted - 2007-04-30 : 19:04:27
quote:
Originally posted by jezemine

it can be done. have a look at Jeff's articles here: http://weblogs.sqlteam.com/jeffs/category/162.aspx


www.elsasoft.org



Nice to do it on the server side, but I'm still astonished that SQL Server doesn't have a way to just skip X records when doing a SELECT.

-D. Israel
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-30 : 19:47:00
It does as of SQL 2005, did you read the link Kristen provided ?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2007-04-30 : 23:13:54
quote:


Nice to do it on the server side, but I'm still astonished that SQL Server doesn't have a way to just skip X records when doing a SELECT.




Yes & no. Databases are typically used to get exactly those records you want, not those that you want and a few others mixed in.

The idea is that it is up to you to specify what you want to get out by supplying a query that satisfies your criteria at the time.

The whole concept of pages does not really fit well with the relational model (or a multiuser system for that matter) but I know what you mean. If you simply want to break up into pages then best do this in the front end or reporting tool. If you're thinking web pages then you need to specify or use some of the ideas above.
Go to Top of Page

Daniel Israel
Starting Member

15 Posts

Posted - 2007-05-03 : 15:51:38
quote:
Originally posted by jsmith8858

It does as of SQL 2005, did you read the link Kristen provided ?

- Jeff
http://weblogs.sqlteam.com/JeffS




Yes I did, but unfortunately, I'm not using 2005 yet.

quote:
Originally posted by LoztInSpace



Yes & no. Databases are typically used to get exactly those records you want, not those that you want and a few others mixed in.

The idea is that it is up to you to specify what you want to get out by supplying a query that satisfies your criteria at the time.

The whole concept of pages does not really fit well with the relational model (or a multiuser system for that matter) but I know what you mean. If you simply want to break up into pages then best do this in the front end or reporting tool. If you're thinking web pages then you need to specify or use some of the ideas above.



Yea, I'm going to have to implement one of these on the server. Which is not a WORST case, but it would have been nice.

Thanks guys for all the help.


-D. Israel
Go to Top of Page
   

- Advertisement -