Just Code‎ > ‎

T-SQL: The difference between @@identity, scope_identity(), and ident_current()

posted Oct 22, 2009, 2:24 AM by Peter Henell   [ updated Aug 20, 2012, 6:57 AM ]
Detailed Post: http://blog.falafel.com/2008/04/23/TSQLTheDifferenceBetweenIdentityScopeidentityAndIdentcurrent.aspx


  • @@identity: identity value from this session but any scope (triggers and such might give unexpected results as they run in another scope)
  • scope_identity(): identity value from this session and this scope (even if triggers created identity values in other tables they will not be returned from this even tho they are created in the same session)
  • ident_current(): identity value from for a specific table in any session and any scope



Comments