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)
 get last record in sql server

Author  Topic 

pu_jan
Starting Member

2 Posts

Posted - 2002-05-21 : 04:02:20


how to get last record in Sql SErver

thank u for help me

best regard
pujan

macka
Posting Yak Master

162 Posts

Posted - 2002-05-21 : 04:23:36
pujan,

Try this:

USE northwind

SELECT TOP 1 * FROM Orders
ORDER BY OrderID DESC

macka

Go to Top of Page

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2002-05-21 : 10:27:46
pujan,

Your question is relative. SQL Server does not store records in any particular order outside of the ordering constraints of a clustered index. Unless you specify the ordering of your data and therefore decide what you will designate as the last record. If you an ordering scheme to the table such as with an identity column then you will have a last record from an end user perspective but not from a SQL perspective.

m2c,
Justin

Go to Top of Page
   

- Advertisement -