INSERT INTO from two different server database

后端 未结 5 1856
走了就别回头了
走了就别回头了 2021-02-02 10:07

I am trying to copy the data of testdabse.invoice table to basecampdev.invoice table. testdabse is a local database while basecampde

5条回答
  •  深忆病人
    2021-02-02 10:43

    USE [mydb1]
    
    SELECT *
    INTO mytable1
    FROM OPENDATASOURCE (
            'SQLNCLI'
            ,'Data Source=XXX.XX.XX.XXX;Initial Catalog=mydb2;User ID=XXX;Password=XXXX'
            ).[mydb2].dbo.mytable2
        /*  steps - 
                1-  [mydb1] means our opend connection database 
                2-  mytable1 means create copy table in mydb1 database where we want insert record
                3-  XXX.XX.XX.XXX - another server name.
                4-  mydb2 another server database.
                5-  write User id and Password of another server credential
                6-  mytable2 is another server table where u fetch record from it. */
    

提交回复
热议问题