|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
sql query copy databaseI 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 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 Col2 , Col3 , Col5 , etc FROM database2.dbo.table WHERE ID > 400 -- Show quoteArnie Rowland "To be successful, your heart must accompany your knowledge." "Howard" <howdy0***@yahoo.com> wrote in message news:uaWV%23v8pGHA.3584@TK2MSFTNGP03.phx.gbl... >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 > > |
|||||||||||||||||||||||