2

don't know why this code is not executing...

SET IDENTITY_INSERT COM_MST ON
GO
INSERT INTO COM_MST 
SELECT * FROM COM_MST_DEL

and showing an error

An explicit value for the identity column in table 'COM_MST' can only be specified when a column list is used and IDENTITY_INSERT is ON.
Nisar
  • 5,708
  • 17
  • 68
  • 83
  • I'm always amazed that people don't spot the *and* in the middle of the error message and realize that there are *two* conditions that they have to fulfill. – Damien_The_Unbeliever Aug 27 '13 at 06:46

2 Answers2

8

You have to specify the columns in the insert statement

user172839
  • 1,035
  • 1
  • 10
  • 19
1
SET IDENTITY_INSERT COM_MST ON
GO
INSERT INTO COM_MST 
SELECT * FROM COM_MST_DEL

In this your select statement SELECT * FROM COM_MST_DEL might be returning more than the column available in table COM_MST also make sure to specify the column name in Insert statement.

OR

See the solution proposed in the post An explicit value for the identity column in table can only be specified when a column list is used and IDENTITY_INSERT is ON SQL Server

Community
  • 1
  • 1
Harish Bhatt
  • 584
  • 6
  • 15