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 |
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-02-09 : 05:23:28
|
| hi,i need to select last inserted record in my table,can any one show some example query for that please |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-09 : 05:31:11
|
| Not possible unless you are recording the datetime when record was inserted or using rowversion column in the table.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-02-09 : 05:47:39
|
| hi harsh_athalye i am javing updated date as datecolumn in my database.so now cani get lastinserted record in my table please show some examplemy table has the following columns: name id updated_date |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-09 : 05:50:40
|
| [code]Select TOP 1 * from tblorder by Updated_date DESC[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sqllover
Constraint Violating Yak Guru
338 Posts |
Posted - 2007-02-09 : 06:12:59
|
| thanks harsh_athalye i did that |
 |
|
|
a4nsd
Starting Member
20 Posts |
Posted - 2007-02-11 : 02:10:33
|
| Hi sqlloverIf you id field in table and set autocreament =1 & primary key. U can try thisselect * from tbl_Products Where ProductID=(Select Max(ProductID) from tbl_Products) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-02-11 : 05:27:23
|
"If you id field in table and set autocreament =1 "This may be fasterSELECT TOP 1 Col1, Col2, ...FROM tbl_Products ORDER BY ProductID DESC Kristen |
 |
|
|
|
|
|