Error 544

Severity Level 16

Message Text

Attempting to insert explicit value for identity column in table '%.*s' when IDENTITY_INSERT is set to OFF

Explanation

This error occurs when you have attempted to insert a row that contains a specific identity value into a table that contains an identity column. However, the IDENTITY_INSERT property is not enabled for the specified table.

Action

To successfully insert a specific identity row into a table containing an identity column, you must enable the IDENTITY_INSERT option. The following example inserts identity row 2, where iID is defined as the identity column.

Table: tblTest

iID    strData
1    Jones
3    Smith

/* Enable IDENTITY_INSERT */    
set IDENTITY_INSERT tblTest ON
go

/* Insert the specified identity row using a column list */
insert into tblTest (iID, strData) values (2, "Lambert")
go

/* Disable IDENTITY_INSERT */
set IDENTITY_INSERT tblTest OFF
go