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.
Author |
Topic |
gperque
Starting Member
7 Posts |
Posted - 2007-09-12 : 12:06:12
|
Hi All,I would like to retrieve the last 5 records entered in a table. How would I construct the stored procedure to do this? I familar with ordering the results in descending order, but I would only like to see the last 5 records entered.Thanks in advance,Glenn |
|
X002548
Not Just a Number
15586 Posts |
|
Kristen
Test
22859 Posts |
Posted - 2007-09-12 : 14:22:20
|
"the last 5 records entered in a table"SQL has no concept of the order in which data is added, so you would need a "Date Added" column, or maybe an incrementing identity, or something similar, in order to be able to "Order By" in the sequence you want - as Brett has describedKristen |
 |
|
gperque
Starting Member
7 Posts |
Posted - 2007-09-20 : 15:12:06
|
Thanks all, I do have a date column and when I retrieved the "TOP 5", it received the data I required. |
 |
|
|
|
|