|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Hi,
I need to get the value of newly inserted Id in my table. I know I can use @@identity to get it, however this might not be the one I need, since if somebody else inserted another record at the same time I might end up to get that one. Is there a way to make sure I get my recently inserted Id? Thanks, |
|
#2
|
|||
|
|||
|
Might help to tell us which DB system you are using
. |
|
#3
|
||||
|
||||
|
Smells like MSSQL Server.
>> Is there a way to make sure I get my recently inserted Id? Yeah, do the insert and the select within a transaction and lock the table before inserting. |
|
#4
|
|||
|
|||
|
Hi,
Sorry, I forgot. It is MS SOL server. I read an article for MS SQL while ago and in there they mentioned another method for getting the identity for SQL 2000. Do you know where can I fond some info on it? Thanks, |
|
#5
|
|||
|
|||
|
It will not matter if anybody else makes an insert after yours. That will not affect what is returned by @@identity
@@indetity contains the value of the most recent identity value within a connection. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > @@Identity |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|