Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting query progress from SQL Server
Message
From
01/12/2000 09:42:36
 
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00446850
Message ID:
00448012
Views:
6
Paging is a popular topic with no easy answer. I've seen a couple of techniques, most make use of server-side cursors to allow for jumping to absolute positions.

I have one idea but I've never had an opportunity to implement it. If you know the column that you want to sort on, the value and PK from the first row and the value and PK from the last row, it becomes easy to page throught the table.

To move to the next page:

SELECT TOP 50 *
FROM table
WHERE column >= last_column_value AND PK > last_PK_value
ORDER BY column, PK ASC

To move to the previous page

SELECT TOP 50 *
FROM table
WHERE column <= last_column_value AND PK < last_PK_value
ORDER BY column, PK DESC

This last set will return the value backwards. It shouldn't be too hard to flip them.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Reply
Map
View

Click here to load this message in the networking platform