T-SQL Tutorial

T-SQL @@Identity


The identity function is a system function that returns the last inserted identity value.

@@Identity Syntax

@@IDENTITY;

@@Identity Example

USE model;
GO
insert into students(id,first_name, last_name, gender,city, country)
values(7,'Ashley','THOMPSON','F','Liverpool','England');
GO
SELECT @@IDENTITY AS 'Identity';
GO
SELECT MAX(id) as Result FROM students;
GO

Result
7

See also:
T-SQL Functions -> @@MAX_CONNECTIONS