且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当 IDENTITY_INSERT 设置为 OFF 时,无法在表“表"中插入标识列的显式值

更新时间:2023-01-22 08:52:10

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