简体   繁体   English

有没有一种简单的方法可以在SQL Server 2014上本地复制SQL Azure数据库?

[英]Is there a simple way to copy a SQL Azure Database locally on SQL Server 2014?

I have created a bacpac file through the Export option of Azure. 我已经通过Azure的“ 导出”选项创建了一个bacpac文件。

Then, I tried to import the bacpac file into SQL Server installed locally on my pc, selecting in SQL Server Management Studio, the “ Import Data-tier Application… ” feature. 然后,我尝试将bacpac文件导入到本地安装在我的PC上的SQL Server中,在SQL Server Management Studio中选择“ 导入数据层应用程序… ”功能。

The import fails becouse the destination version of sql server is not the same of the source (namely from Sql Azure to SQL Server 2014). 导入失败,因为sql server的目标版本与源版本不同(即从Sql Azure到SQL Server 2014)。 I have in fact locally installed on my pc SQL Server 2014. 我实际上已经在本地安装了我的PC SQL Server 2014。

To fix the problem I should create a new SQL Server database project in Visual Studio 2017 , remove some incompatibilities like the following: 若要解决此问题,我应该在Visual Studio 2017中创建一个新的SQL Server数据库项目,删除一些类似以下的不兼容性:

--CREATE DATABASE SCOPED CREDENTIAL
--    WITH IDENTITY = N'SHARED ACCESS SIGNATURE';

Then I should publish the project to create a new db locally. 然后,我应该发布该项目以在本地创建一个新的数据库。

But the new db obtained publishing the Visual Studio Project is empty and so I have to manually copy the data, cause the Import Data function in SSMS doesn't work because of some problems like column identity. 但是获得的发布Visual Studio Project的新数据库是空的,因此我必须手动复制数据,因为诸如列标识之类的问题,导致SSMS中的Import Data函数无法正常工作。

Is there a quick and simple way of creating a local copy of a SQL Azure Database on my local SQL Server? 有没有在我的本地SQL Server上创建SQL Azure数据库的本地副本的快速简便方法?

Thanks 谢谢

You can try the below steps and see if it helps, 您可以尝试以下步骤,看看是否有帮助,

  1. Open your SQL Management Studio and connect to your Azure SQL Server. 打开您的SQL Management Studio并连接到Azure SQL Server。
  2. Select the database you would like to get down onto your local machine and right-click -> select "Generate Scripts". 选择您要进入本地计算机的数据库,然后右键单击->选择“生成脚本”。 Follow the prompts. 按照提示进行操作。

If you want the data as well as the scripts, you need to check the Advanced Options before beginning the generating. 如果需要数据和脚本,则需要在开始生成之前检查“高级选项”。 Scroll down to "Types of data to script" and make sure you have "Schema and data" or whatever is appropriate for you. 向下滚动到“要脚本的数据类型”,并确保您具有“架构和数据”或任何适合您的内容。 You will get a SQL script file. 您将获得一个SQL脚本文件。 Then you can run that on your local machine and it will create a database with all the data. 然后,您可以在本地计算机上运行该数据库,它将创建一个包含所有数据的数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM