Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 NEXT RECORD FROM DB

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-23 : 09:02:55
Andris writes "Hello
I have a specific situation:
Imagine that i have a database with records. Then I retrieve a record with specific number, but a query should return me the next record. For instance, if I have a database with records 1,2,3,4,5 and I write SELECT * FROM table WHERE ID=1
The query would return a record with ID number 1. But how could I make a query to retrieve not record with ID 1, but record with ID 2. The most important point is that some ID numbers in my database are missing. For example 1,2,3,5 (4 is missing).

Hope You could help me
Andris

[I have WINNT and SQL SERVER 2000]"

Nazim
A custom title

1408 Posts

Posted - 2002-04-23 : 09:08:09

select top 1 * from tablename
where id > 1
order by id asc


HTH


--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -