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 |
|
meyya1180
Starting Member
1 Post |
Posted - 2009-04-05 : 01:26:58
|
| Hi Team,I am currently working on test automation and now i am designing a script in VB to get the most recently inserted record from a table.When i asked my friends they told that the recently inserted record will be the last record of the table.But when i was implementing this script i found that the records which inserted in to the table using a vb.net went in to the middle of the table.When i checked why this happened i found that that the developer has given identity based on two columns.after explaining the whole scenario would someone help me to retrieve the most recently inserted record using VB. |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2009-04-05 : 08:45:44
|
| Put a new column in the table as InsertedDateTime & put the default value as getdate().You can get the latest inserted value w.r.t that column. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-04-05 : 23:59:04
|
| suppose u hav a datetime column, then select * from urtable order by column desc(or) select * from urtable order by 1 desc(or) select max(id) from urtable |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-04-06 : 00:59:11
|
| select top 1 * from table order by id descRegardsSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceled |
 |
|
|
|
|
|