AzureTipsAndTricks/blog/tip140.md

37 строки
2.0 KiB
Markdown
Исходник Обычный вид История

2020-10-16 02:29:48 +03:00
---
type: post
title: "Tip 140 - Easily copy your SQL Azure database to your local development server"
excerpt: "Learn how to easily copy your SQL Azure database to your local development server"
tags: [Databases]
2020-10-16 02:29:48 +03:00
date: 2018-07-15 17:00:00
---
::: tip
:bulb: Learn more : [Azure SQL Database Documentation](https://docs.microsoft.com/azure/sql-database?WT.mc_id=docs-azuredevtips-azureappsdev).
:::
### Easily copy your SQL Azure database to your local development server
2020-10-16 02:29:48 +03:00
I've ran across folks at conferences that asked me "How do you copy a SQL Azure database to my local development machine?" While chatting with them, I always found it difficult to understand why (as it is dirt cheap to have a development SQL Azure instance in the cloud) but nevertheless it is their data and there is an easy way to do this.
2020-10-16 02:29:48 +03:00
First off, [download SQL Server Management Studio (SSMS)](https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-2017?WT.mc_id=docs-azuredevtips-azureappsdev) and connect to your SQL Azure database that you want to copy locally.
**Note by cbattlegear** One important caveat to this process (as shown below). If any writes are happening on the database while you do the export the import will be broken. Best practice is to run `CREATE DATABASE AS COPY` to create a copy of the database and create an export of the copy.
Right-click on the **Database** -> click **Tasks** > **Export data-tier application**
<img :src="$withBase('/files/sqlazure1.png')">
You'll see a wizard and will export your database to a local .bacpac file.
<img :src="$withBase('/files/sqlazure2.png')">
You'll see something similar to this screen once it has finished processing.
2020-10-16 02:29:48 +03:00
<img :src="$withBase('/files/sqlazure4.png')">
Now ensure you are connected to your local target SQL server instance (or SQL Azure instance) and right-click on **Databases** (the parent folder of your actual database) -> click **Tasks** > **Import data-tier application** and select the .backpac file that you created earlier.
2020-10-16 02:29:48 +03:00
<img :src="$withBase('/files/sqlazure3.png')">