Sqlserver insert 带有自增 pk 的错误

Msg 544, Level 16, State 1, Line 1
Cannot insert explicit value for identity column in table 'CM_EVENT' when IDENTITY_INSERT is set to OFF.

table you 有三列:  Event_ID,Event_Date,Event_Type_Code

insert into  
CM_EVENT(Event_ID,Event_Date,Event_Type_Code)
values
(1,getdate(),1)

运行时候出错,因为Event_ID是一个自增的ID

改为
insert into  
CM_EVENT(Event_Date,Event_Type_Code)
values
(getdate(),1)


你可能感兴趣的:(SQL Server,sqlserver,Msg 544,Level 16)