To insert identity values in a table there is a function IDENTITY_INSERT that needs to be set on a table before Insert statement is executed.
Example:
Example:
SET IDENTITY_INSERT Table1 ON
INSERT INTO Table1
(Id, firstname, lastname)
(SELECT Id, firstname, lastname
FROM Table2)
SET IDENTITY_INSERT Table1 OFF
INSERT INTO Table1
(Id, firstname, lastname)
(SELECT Id, firstname, lastname
FROM Table2)
SET IDENTITY_INSERT Table1 OFF
No comments:
Post a Comment