Export table data from one SQL Server to another

后端 未结 12 730
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 07:29

I have two SQL Servers (both 2005 version).

I want to migrate several tables from one to another.

I have tried:

  • On source server I have righ

12条回答
  •  情话喂你
    2020-12-02 07:55

    Just for the kicks.

    Since I wasnt able to create linked server and since just connecting to production server was not enough to use INSERT INTO i did the following:

    • created a backup of production server database
    • restored the database on my test server
    • executed the insert into statements

    Its a backdoor solution, but since i had problems it worked for me.

    Since i have created empty tables using SCRIPT TABLE AS / CREATE in order to transfer all the keys and indexes I couldnt use SELECT INTO. SELECT INTO only works if the tables do not exist on the destination location but it does not copy keys and indexes, so you have to do that manualy. The downside of using INSERT INTO statement is that you have to manualy provide with all the column names, plus it might give you some problems if some foreign key constraints fail.

    Thanks to all anwsers, there are some great solutions but i have decided to accept marc_s anwser.

提交回复
热议问题