Home All Groups Group Topic Archive Search About

sql query copy database

Author
15 Jul 2006 5:03 AM
Howard
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

Author
15 Jul 2006 5:55 AM
Arnie Rowland
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

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



Show quote
"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
>
>

AddThis Social Bookmark Button