using @@IDENTITY which returns the last-inserted identity value
But the preferable solution is to use IDENT_CURRENT('TableName') which
returns the last identity value generated for a specified table in any
session and any scope.
How can I get the next auto increment value from mssql?
