IDENTITY PROPERTY




The IDENTITY property makes generating unique values easy. IDENTITY isn't a datatype. It's a column property.

Ex: CREATE TABLE Customer(cust_id smallint IDENTITY NOT NULL, cust_name VARCHAR(50) NOT NULL)

The system function @@IDENTITY contains the last identity value used by the connection.

SELECT @@IDENTITY:- If a trigger was fired for the INSERT, the value of @@IDENTITY might have changed.

SELECT SCOPE_IDENTITY:- If an INSERT trigger also inserted a row that contained an identity column, it would be in a different scope.

SELECT IDENT_CURRENT('Customer'): - To know the last IDENTITY value inserted in a specific TABLE from any application or user.