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 |
|
tyh2003
Starting Member
3 Posts |
Posted - 2009-03-19 : 03:12:02
|
| I have a table its primary key is set to be auto increment, when i insert a new record,how could i obtain the id corresponding to the new record in just one sql command execution??thks in advance |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-03-19 : 03:15:49
|
| Use SCOPE_IDENTITY() Functioninsert into table(...)@id=scope_identity()Select @idRegardsSenthil.C----------------------------------------------------------------------------Server: Msg 3902, Level 16, State 1, Line 1The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-19 : 11:04:09
|
quote: Originally posted by senthil_nagore Use SCOPE_IDENTITY() Functioninsert into table(...)set @id=scope_identity()Select @idRegardsSenthil.C----------------------------------------------------------------------------Server: Msg 3902, Level 16, State 1, Line 1The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|