Friday, March 13, 2020

How to insert value into primary key column in SQL Server?

if you got this error message when trying to run this SQL: An explicit value for the identity column in table 'Student' can only be specified when a column list is used and IDENTITY_INSERT is ON.
Used below query 

SET IDENTITY_INSERT StudentON;
Insert into Student(classID,ClassName,schoolID) values(1976,'Grade 1',178)
SET IDENTITY_INSERT Student OFF;

===================================================================
Thank you 

1 comment: