my goal is to select items from a table and append those items into another table located on a remote database on the same server. All columns in both tables match up and are identical. In this case,
I have the tsql:
INSERT INTO db1.dbo.tblitems
SELECT *
FROM db2.dbo.tblitems i2
WHERE i2 = 'import'
i get an error saying:
An explicit value for the identity column in table ‘db1.dbo.tblitems’ can only be specified when a column list is used and IDENTITY_INSERT is ON.
any ideas why this doesn’t work?
thanks in advance
Sounds like there is an identity column in the table. An identity column is a column that is made up of values generated by the database. For example:
This gives the
identity columnerror. You can avoid that in two ways: the first is not to insert the identity column, like:The second is to use
set identity_insert(requires admin privileges):In both cases, you have to specify the column list.