Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting query progress from SQL Server
Message
De
01/12/2000 09:42:36
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00446850
Message ID:
00448012
Vues:
11
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform