all groups > sql server programming > july 2006 >
You're in the

sql server programming

group:

sql query copy database


sql query copy database Howard
7/14/2006 10:03:12 PM
sql server programming: I have two databases, both have a table with the exact same structure. i
would like to merge the two databases, copy TABLE from database2 to TABLE
database1 where ID column in database2 > 400

thanks
Howard

Re: sql query copy database Arnie Rowland
7/14/2006 10:55:54 PM
If the tables do not have IDENTITY columns, then this could work.

INSERT INTO database1.dbo.table
SELECT *
FROM database2.dbo.table
WHERE ID > 400

If the receiving table had an IDENTITY column, then add the following =
clarifications:

(Assuming Col1 is the IDENTITY column.)

INSERT INTO database1.dbo.table
( Col2
, Col3
, Col4
, etc
)
SELECT=20
Col2
, Col3
, Col5
, etc
FROM database2.dbo.table
WHERE ID > 400

--=20
Arnie Rowland
"To be successful, your heart must accompany your knowledge."



[quoted text, click to view]
AddThis Social Bookmark Button