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
 General SQL Server Forums
 New to SQL Server Programming
 How to select last record in table

Author  Topic 

norty911
Starting Member

41 Posts

Posted - 2007-10-15 : 09:06:22
Hey guys, is there an easy way to select the very last record in a table?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-15 : 09:07:51
what is your definition of last record ?

you can use TOP 1 with ORDER BY ASC or DESC to do it.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-15 : 09:07:55
Define what you mean by "Very Last Record". In relational world there is no First or Last record. In fact, you can't retrieve any record based on position.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-15 : 09:14:33


Mere 4 secs!

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-15 : 09:21:59
quote:
Originally posted by norty911

Hey guys, is there an easy way to select the very last record in a table?


Does your table have identity column/datetime column?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

norty911
Starting Member

41 Posts

Posted - 2007-10-15 : 10:52:52
Thanks for the replies... have found my solution - similar to what khtan
Go to Top of Page
   

- Advertisement -