Return the identity value for an inserted row in SQL SERVER

We have several statements for returning the identity value for an inserted row.
  
1)scope_identity()
2)ident_current
3)@@identity

1) scope_identity() will return the last identity inserted in the current scope and session.
2)ident_current('Table Name') returns the last value inserted into that table on any connection. Remember to put the table name in quotes
3)@@identity will return the last identity value inserted in any scope.

No comments:

Post a Comment