I am making selections from database A and want to dump the results into database B.
Today i am running this statement:
USE BDotSheppard
SELECT *
INTO dbo.Addresses
FROM BDotDev.dbo.Addresses
WHERE UserId = 15304
Later on ill run
USE BDotSheppard
SELECT *
INTO dbo.Addresses
FROM BDotDev.dbo.Addresses
WHERE UserId = 15555
The problem is that when I run the second one it says that the object already exists and won't dump the data on top of the data I already have.
How can i simply add the data to this already existing object ?
It wont work, the first statement copies the ID's, and as part of the the design of the table it sets the first id to be autoincrement. When i run the second one it fails
Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'dbo.Addresses' can only be specified when a column list is used and IDENTITY_INSERT is ON.
SET IDENTITY_INSERT BDotSheppard.dbo.Addresses ON
INSERT INTO dbo.Addresses
SELECT *
FROM BDotDev.dbo.Addresses
WHERE UserId = 15555
SET IDENTITY_INSERT dbo.Addresses OFF
This is the error:
Msg 8101, Level 16, State 1, Line 2
An explicit value for the identity column in table 'dbo.Addresses' can only be specified when a column list is used and IDENTITY_INSERT is ON.
Msg 8101, Level 16, State 1, Line 3
An explicit value for the identity column in table 'dbo.Addresses' can only be specified when a column list is used and IDENTITY_INSERT is ON.
Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'dbo.Addresses' can only be specified when a column list is used and IDENTITY_INSERT is ON.