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.
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.