Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving a record pointer.
Message
From
11/10/2000 08:29:46
 
 
To
11/10/2000 00:19:27
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00427244
Message ID:
00427756
Views:
15
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform