SQL SERVER – @@IDENTITY – Identity Column @SQLSERVER
@@IDENTITY : This system function is used to get the identity column value that is recently inserted into a table. This function is active within the current session. But, the function SCOPE_IDENTITY is active within the scope of a statement.
It returns a numeric data type of size numeric(38,0)
1. I have already created a table and inserted few rows. I am going to use that table in this example.
CREATE TABLE [dbo].[tblIdentity](
[RowID] [int] IDENTITY(1,1) NOT NULL,
) ON [PRIMARY]
2. Executing the function @@IDENTITY in the current session gives us the last inserted value.