|
Site Seeder Question: If I use @@IDENTITY to return the last inserted IDENTITY value, then this works up to the point that I create a trigger on the table that is being affected that also inserts a row into a table with an IDENTITY column. How can I get around this?
(comments are locked)
|
|
If you are on 2005 or 2008 I recommend using the OUTPUT clause. There are a couple of known issues with SCOPE_IDENTITY() as well. See Connect Items #328811 and #476577 I agree with Jack, if you are on a newer version, kick this back with the OUTPUT clause.
Oct 12 '09 at 11:10 AM
Steve Jones - Editor ♦♦
(comments are locked)
|
|
You can use
(comments are locked)
|
|
@@IDENTITY returns the last identity value in the current connection. IDENT_CURRENT returns the last in the table. It's not the same thing as @@IDENTITY at all. Use SCOPE_IDENTITY() instead of @@IDENTITY if you want to ignore values generated by triggers.
(comments are locked)
|
|
IDENT_CURRENT() has its own sets of issues (specifically related to transactions) and I haven't come across any situation where I would need it.
(comments are locked)
|
|
If you are wanting to return the created identity of a specific table you can use
(comments are locked)
|

