Export table data from one SQL Server to another

后端 未结 12 667
伪装坚强ぢ
伪装坚强ぢ 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:37

    Just to show yet another option (for SQL Server 2008 and above):

    1. right-click on Database -> select 'Tasks' -> select 'Generate Scripts'
    2. Select specific database objects you want to copy. Let's say one or more tables. Click Next
    3. Click Advanced and scroll down to 'Types of Data to script' and choose 'Schema and Data'. Click OK
    4. Choose where to save generated script and proceed by clicking Next
    0 讨论(0)
  • 2020-12-02 07:38

    This is somewhat a go around solution but it worked for me I hope it works for this problem for others as well:

    You can run the select SQL query on the table that you want to export and save the result as .xls in you drive.

    Now create the table you want to add data with all the columns and indexes. This can be easily done with the right click on the actual table and selecting Create To script option.

    Now you can right click on the DB where you want to add you table and select the Tasks>Import .

    Import Export wizard opens and select next.Select the Microsoft Excel as input Data source and then browse and select the .xls file you have saved earlier.

    Now select the destination server and also the destination table we have created already.

    Note:If there is any identity based field, in the destination table you might want to remove the identity property as this data will also be inserted . So if you had this one as Identity property only then it would error out the import process.

    Now hit next and hit finish and it will show you how many records are being imported and return success if no errors occur.

    0 讨论(0)
  • 2020-12-02 07:40

    If you don't have permission to link servers, here are the steps to import a table from one server to another using Sql Server Import/Export Wizard:

    • Right click on the source database you want to copy from.
    • Select Tasks - Export Data.
    • Select Sql Server Native Client in the data source.
    • Select your authentication type (Sql Server or Windows authentication).
    • Select the source database.
    • Next, choose the Destination: Sql Server Native Client
    • Type in your Server Name (the server you want to copy the table to).
    • Select your authentication type (Sql Server or Windows authentication).
    • Select the destination database.
    • Select Copy data.
    • Select your table from the list.
    • Hit Next, Select Run immediately, or optionally, you can also save the package to a file or Sql Server if you want to run it later.
    • Finish
    0 讨论(0)
  • 2020-12-02 07:41

    There is script table option in Tasks/Generate scripts! I also missed it at beginning! But you can generate insert scripts there (very nice feature, but in very un-intuitive place).

    When you get to step "Set Scripting Options" go to "Advanced" tab.

    Steps described here (pictures can understand, but i do write in latvian there).

    0 讨论(0)
  • 2020-12-02 07:48

    Try using the SQL Server Import and Export Wizard (under Tasks -> Export Data).

    It offers to create the tables in the destination database. Whereas, as you've seen, the scripting wizard can only create the table structure.

    0 讨论(0)
  • 2020-12-02 07:50

    It can be done through "Import/Export Data..." in SQL Server Management Studio

    0 讨论(0)
提交回复
热议问题