Skip to content

IDENTITY_INSERT

SET IDENTITY_INSERT dbo.YourTable ON;
INSERT INTO dbo.YourTable (ID, Name)
VALUES (5, 'Sam');
SET IDENTITY_INSERT dbo.YourTable OFF;

New entry in YourTable:

IDName
5Sam

In the example provided, the IDENTITY_INSERT property was enabled for YourTable, allowing an explicit value (in this case, ‘5’) to be inserted into the identity column ‘ID’. The name column received the value ‘Sam’. After inserting the data, the IDENTITY_INSERT property was turned off to ensure the SQL Server manages the identity column automatically again.