SQL Azure - copy table between databases

后端 未结 12 2357
天命终不由人
天命终不由人 2020-12-08 13:39

I am trying to run following SQL:

INSERT INTO Suppliers ( [SupplierID], [CompanyName]) 
Select  [SupplierID], [CompanyName] From [AlexDB]..Suppliers
<         


        
相关标签:
12条回答
  • 2020-12-08 14:07

    I would recommend SSMS SQL Server Import and Export feature. This feature supports multiple connection configurations and cross-server copy of selected tables. I have tried .NET Sql Server connector, which works very well for the Azure SQL databases.

    0 讨论(0)
  • 2020-12-08 14:09

    Ok, i think i found answer - no way. have to move data to client, or do some other tricks. Here a link to article with explanations: Limitations of SQL Azure: only one DB per connection But any other ideas are welcome!

    0 讨论(0)
  • 2020-12-08 14:09

    A few options (rather workarounds):

    1. Generate script with data
    2. Use data sync in Azure
    3. Use MS Access (import and then export), with many exclusions (like no GUID in Access)
    4. Use 3-rd party tools like Red Gate.

    Unfortunately no easy and built-in way to do that so far.

    0 讨论(0)
  • 2020-12-08 14:11

    I know this is old, but I had another manual solution for a one off run.

    Using SQL Management Studio R2 SP1 to connect to azure, I right click the source database and select generate scripts.

    during the wizard, after I have selected my tables I select that I want to output to a query window, then I click advanced. About half way down the properties window there is an option for "type of data to script". I select that and change it to "data only", then I finish the wizard.

    All I do then is check the script, rearrange the inserts for constraints, and change the using at the top to run it against my target DB.

    Then I right click on the target database and select new query, copy the script into it, and run it.

    Done, Data migrated.

    hope that helps someone

    0 讨论(0)
  • 2020-12-08 14:14

    An old post, but another option is the Sql Azure Migration wizard

    0 讨论(0)
  • 2020-12-08 14:18

    SQL-Azure does not support USE statement and effectively no cross-db queries. So the above query is bound to fail.

    If you want to copy/backup the db to another sql azure db you can use the "Same-server" copying or "Cross-Server" copying in SQL-Azure. Refer this msdn article

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