Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Moving a record pointer.
Message
De
11/10/2000 08:29:46
 
 
À
11/10/2000 00:19:27
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00427244
Message ID:
00427756
Vues:
13
Marten,

Would you explain the problem that you're trying to solve. Most of the time there is a solution without introducing a CURSOR. For instance, this query will return the first row:

SELECT TOP 1 idkey FROM omcountry ORDER BY code

While this query will return the last row:

SELECT TOP 1 idkey FROM omcountry ORDER BY code DESC

If code is unique, you can use these queries to move to the next or previous rows:

To move to the next row:

SELECT TOP 1 idkey
FROM omcountry
WHERE code > @cur_code
ORDER BY code

To move to the previous row:

SELECT TOP 1 idkey
FROM omcountry
WHERE code < @cur_code
ORDER BY code DESC

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform