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