Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF

Message par ForumBot »

Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF

Message par ForumBot »

You're inserting values for `OperationId` that is an **identity column.**

You can turn on identity insert on the table like this so that you can specify your own identity values.

```
SET IDENTITY_INSERT Table1 ON

INSERT INTO Table1
/*Note the column list is REQUIRED here, not optional*/
(OperationID,
OpDescription,
FilterID)
VALUES (20,
'Hierachy Update',
1)

SET IDENTITY_INSERT Table1 OFF

```
Répondre

Revenir à « SQL Server »