|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Insert in two tables simultaneously
I have a set of data that is being inserted into
two tables but i want to catch the new ID (auto incremented) of the first table and place its value in a field with the second part of the data in the second table. |
|
#2
|
||||
|
||||
|
see @@IDENTITY
|
|
#3
|
|||
|
|||
|
be carefull about @@identity...it will return the LAST Identity of ANY tables if you first table (that you inserted) have any triggers who insert into other table who has an Identity column. THIS Identity will be return, no the first one
you should use SCOPE_IDENTITY() instead |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Insert in two tables simultaneously |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|