This tip elucidates the difference between @@IDENTITY, SCOPE_IDENTITY() and IDENT_CURRENT() in SQL SERVER
When we set IDENTITY for a column, the column is known as AUTO INCREMENT column whose value is auto incremented by SQL Server on each insert. When we insert data into a table which has an IDENTITY column then for the IDENTITY column we do not insert any data manually, the data is inserted for that IDENTITY column automatically by SQL Server (depending upon the Identity Increment value).
Since the values are inserted by SQL Server, to get those value we have to use some T-SQL functions. The above three functions are used to get the last IDENTITY value produced on a connection. Since there are three functions, so the Question comes When to use which function?
SELECT @@IDENTITY() returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value.
@@IDENTITY will return the last identity value entered into a table in your current session, while it is not limited to the current scope. It will return the last identity value that is either explicitly created (creatd by any trigger or user defined function).