Identity of an Inserted Row
The identity of an inserted row is the last identity column value in a table which was automatically generated by the sql server database system when a new row is added to a table that has an identity column with auto increment set with initial and increment values like the below example.
EmployeeID Int NOT NULL IDENTITY (1,1)
In the above example, the EmployeeID column is created as an identity column to auto increment by 1 with an initial value starting from 1. When a new row is created in the table the EmployeeID will be 1 and it will increment the value by 1 after each row insert subsequently.
How to Get the Identity of an Inserted Row in SQL Server
In SQL Server, we can use an Identity column, which will automatically increment the ID value in a table. The Identity column is a unique, sequential, and non-null value for each row in a table. The identity value is auto-incremented using the IDENTITY command. There could be situations when this auto-incremented value of the Identity column may be required.
In this article, we will discuss the different options available to get the identity value of the inserted row.
Contact Us