Introduction to IDENTITY_INSERT in SQL Server
The identity column is the numeric column in the SQL Server table whose value increments automatically. The value of the identity column is set by the SQL Server itself based on the definition provided by the user. Thus user can not explicitly set the value of such columns and they are unique. The identity column can not be NULL.
Syntax:
IDENTITY [( seed, increment)]
Explanation: Here, seed means the first value to start with while loading the data into the table and increment is the value added to the previous identity value of the column.
How to Turn IDENTITY_INSERT On and Off Using SQL Server?
IDENTITY_INSERT in SQL Server is a valuable tool in SQL Server 2008, allowing us to control how identity values are assigned when inserting new records into a table. IDENTITY_INSERT
ON
is a Transact-SQL statement that allows us to explicitly specify the value we want to insert into the identity column of a table.
In this article, we will understand How to turn IDENTITY_INSERT on and off using SQL Server 2008 with multiple examples and so on.