[SQL Server] Retrieving last generated Identity value
@@IDENTITY:
- Returns the last IDENTITY value generated implicitly (via trigger or user defined function) or explicitly (by user) in current session.
- It returns the value regardless of the scope of the statement and the table.
SCOPE_IDENTITY():
- Returns the last IDENTITY value generated explicitly in current session and by a statement in the same scope.
- It returns the value regardless of the table, generated explicitly rather than any identity that was created by a trigger or a user defined function.
IDENT_CURRENT(<table-name>):
- Returns the last IDENTITY value generated in a table.
- It returns the value regardless of the session and the scope of the statement.
No comments:
Post a Comment