Retrieve Last Inserted Identity
To returns the last IDENTITY value produced on a connection
get last Identity your Session added by your Connection
if they any trigger add to any other tables it will return it
To returns the last IDENTITY value produced on a connection and by a statement in the same scope
To returns the last IDENTITY value produced in a table
it returns the identity value generated for a specific table in any session and any scope
To avoid the potential problems associated with adding a trigger later on, always use SCOPE_IDENTITY() to return the identity of the recently added row in your T SQL Statement or Stored Procedure.
- <code>
- SELECT @@IDENTITY
- </code>
- <code>
- SELECT SCOPE_IDENTITY()
- </code>
- <code>
- SELECT IDENT_CURRENT('tablename')
- </code>