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 2000 Forums
 SQL Server Development (2000)
 How to page result sets to an application

Author  Topic 

Bex
Aged Yak Warrior

580 Posts

Posted - 2005-04-12 : 05:53:59
I have been writing a sproc to return data based on optional parameters provided by the users.

A colleague has asked whether there is a method to limit a result set to an application call (for example, return the first 30 record sets of 300 records that resulted from a query). The reason for doing so, is to prevent too many records crashing the application, and to allow users to page through the results.

One method we thought 0f, was for the first call of the sproc, pass the application the last ID field value (of the 30 selected) to the application. On the second call, the application will pass back this value, and the sproc will select the next TOP 30 using the ID field value as a condition (WHERE CustomerID > @customerID). This will repeat until all record sets have been returned.

However, a flaw with this method is that this assumes that the user will want to chronologically page through the result set.

Can anyone offer any advice or any ideasas how to tackle this problem??

Thanks in advance

Hearty head pats

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-04-12 : 05:56:37
see this:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=48276

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Bex
Aged Yak Warrior

580 Posts

Posted - 2005-04-12 : 06:03:38
Brilliant! Just what I wanted! Thanks Spirit for coming through again!!!

Hearty head pats
Go to Top of Page
   

- Advertisement -