Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I have the below error when I execute the following script. What is the error about, and how it can be resolved?

Insert table(OperationID,OpDescription,FilterID)

values (20,'Hierachy Update',1)

Error:

Server: Msg 544, Level 16, State 1, Line 1

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

1 Answer

0 votes
by (40.4k points)

If you want to insert values for Operation_Id which is an identity column. Then to specify your own identity values, you just turn on the identity insert on the table this way:

SET IDENTITY_INSERT MyTable ON

INSERT INTO MyTable

/*Note: the column list is REQUIRED here, it’s not optional*/

(Operation_ID, OpDescription, Filter_ID)

VALUES (20, 'Hierachy Update',1) SET IDENTITY_INSERT MyTable OFF

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 25, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Jul 4, 2019 in SQL by Tech4ever (20.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...