@@IDENTITY returne the last identity value generated in any table in the current session.
After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY contains the last identity value 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.
The scope of the @@IDENTITY function is the local server on which it is executed. This function cannot be applied to remote or linked servers.
Syntax of @@IDENTITY Function :
@@IDENTITY
Return type of @@IDENTITY function is a numeric.
Examples of @@IDENTITY Function :
Example 1 : Use of @@IDENTITY function in select clause
Output
NULL
Above example returns null as in current session no rows are inserted in any table.