Have a look at SQL SERVER – @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record
Please do note the differences, as stqated below.
I would recomend you look at using IDENT_CURRENT.
IDENT_CURRENT (Transact-SQL)
Returns the last identity value generated for a specified table or
view. The last identity value generated can be for any session and any
scope.
SCOPE_IDENTITY (Transact-SQL)
Returns the last identity value inserted into an identity column in
the same scope. A scope is a module: a stored procedure, trigger,
function, or batch. Therefore, two statements are in the same scope if
they are in the same stored procedure, function, or batch.
@@IDENTITY (Transact-SQL)
After an INSERT, SELECT INTO, or bulk copy statement is completed,
@@IDENTITY contains the last identity value that is generated by the
statement. If the statement did not affect any tables with identity
columns, @@IDENTITY returns NULL. If multiple rows are inserted,
generating multiple identity values, @@IDENTITY returns the last
identity value generated. If the statement fires one or more triggers
that perform inserts that generate identity values, calling @@IDENTITY
immediately after the statement returns the last identity value
generated by the triggers. If a trigger is fired after an insert
action on a table that has an identity column, and the trigger inserts
into another table that does not have an identity column, @@IDENTITY
returns the identity value of the first insert. The @@IDENTITY value
does not revert to a previous setting if the INSERT or SELECT INTO
statement or bulk copy fails, or if the transaction is rolled back.