@@IDENTITY vs SCOPE_IDENTITY()

Have you ever wondered why the @@IDENTITY is not returning the "right" value occassionally when everything was working correctly earlier. Here is the reason.

@@IDENTITY and SCOPE_IDENTITY return the last identity value generated in any table in the current session. However, SCOPE_IDENTITY returns the value only within the current scope; @@IDENTITY is not limited to a specific scope.

Read on here

http://blogs.msdn.com/spike/archive/2009/10/20/my-take-on-identity-vs-scope-identity.aspx

 

No Comments