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 |
|
oguzkaygun
Yak Posting Veteran
53 Posts |
Posted - 2010-03-14 : 10:51:25
|
| HelloHow can i get ID that i inserted a record ?Select @@Identity ?Or Select Scope Identity ?Which one is more good ?Thanks |
|
|
hamid.y
Starting Member
22 Posts |
Posted - 2010-03-14 : 13:37:53
|
| hi,I myself used @@Identity and it works and in my openion its much better than scope Identity because when microsoft did something and make it that much easy and rather optemized, why making trouble? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-03-14 : 14:18:52
|
| @@Identity will give you the wrong value if your table has a trigger that inserts into another table (which uses an Identity). Even if you table does not have a trigger it might do in the future - so using @@Identity you may be creating a bug for the future.Use scope_identity() to avoid this problem. In all other regards it is the same as @@Identity, so I can't think of any reason NOT to use scope_identity()! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|