This article is half-done without your Comment! *** Please share your thoughts via Comment ***
I am sharing important difference between IDENT_CURRENT, @@IDENTITY and SCOPE_IDENTITY of the SQL Server.
Generally, We are using this function to get last inserted identity value for further manipulation.
There is a major difference between this function which is very important to know.
IDENT_CURRENT: returns the last identity value generated for a specific table in any session and any scope.
@@IDENTITY: returns the last identity value generated for any table in the current session, across all scopes.
We should use this carefully because it is not limited to a specific scope and you might be getting last identity value from a trigger instead of your current statement.
SCOPE_IDENTITY: returns the last identity value generated for any table in the current session and the current scope.
Leave a Reply