SELECT @@IDENTITY will return the last identity value entered into a table in your current session.
SELECT SCOPE_IDENTITY() will return the last identity value created in the current session, in the current scope.
SELECT IDENT_CURRENT(‘TABLENAME’) will return the last identity value entered into tablename in your current session, and not only in the current scope.
When using @@IDENTITY, situation that another user will insert newer identity than us can occured, and this can cause us some problems...
@@IDENTITY - current session.
SCOPE_IDENTITY() - current session + current scope.
IDENT_CURRENT(‘TABLENAME’) - current session + specific table.
No comments:
Post a Comment