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
SELECT @@IDENTITY
To returns the last IDENTITY value produced on a connection and by a statement in the same scope
SELECT SCOPE_IDENTITY()
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
SELECT IDENT_CURRENT('tablename')
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.
Comments
Post a Comment