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

Post date: Oct 22, 2009 9:24:30 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