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 |
|
Eagle_f90
Constraint Violating Yak Guru
424 Posts |
Posted - 2011-08-23 : 17:32:39
|
| I am creating a proc that will insert data into a few tables but after the first insert I need to get the uniqie identifier that is placed into the identy column of the newly made row. I know SCOPE_IDENTITY and @@IDENTITY can return that but I am not sure which is best to use. I would think it best to use SCOPE_IDENTITY to get the ID that was created in the one instance of the proc but I might be configuing it with wanting to get it from that one session of the proc. Can anyone tell me which would be better to use to avoide getting the wrong ID in the off case that two people insert new data at the same time using the proc?-- If I get used to envying others...Those things about my self I pride will slowly fade away.-Stellvia |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2011-08-24 : 07:14:27
|
| You may want to look at using the OUTPUT clause of INSERT as detailed in the Microsoft reply to the following:http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=328811 |
 |
|
|
|
|
|