Home > SQL Server > 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)

Function Syntax



1. I have already created a table and inserted few rows. I am going to use that table in this example.

Table Design

CREATE TABLE [dbo].[tblIdentity](
[RowID] [int] IDENTITY(1,1) NOT NULL,
[varchar](10) NULL

Query Execution

pic1This function returns a null value if the insert statement failed or used without insert statement.

2. Executing the function @@IDENTITY in the current session gives us the last inserted value.


  1. No comments yet.
  1. April 29, 2013 at 11:27 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: