Instead of trigger in SQL Server loses SCOPE_IDENTITY?

Use @@identity instead of scope_identity().

While scope_identity() returns the last created id in the current scope, @@identity returns the last created id in the current session.

The scope_identity() function is normally recommended over the @@identity field, as you usually don’t want triggers to interfer with the id, but in this case you do.

Leave a Comment