SQL Azure Database Import / Export v 2.0 is a command line interface to create DacPac for importing / exporting data from SQL Azure to SQL Server and vice versa.
Its available for download from https://www.sqlazurelabs.com/DacImportExportCli.zip (Note: You need to register for SQL Azure Labs for downloading beta programs)
This tool is built upon SQL Server “Denali”
It supports the following versions of SQL Servers
1. SQL Azure
2. SQL Server “Denali”
3. SQL Server 2008 SP1 or above / 2008 R2
4. SQL Server 2005 SP4 and above
5. SQL Server 2000 (Only Export is supported, Import is not supported)
To install and run this, you need the following list of components
1. .Net Framework 4.0
2. SQLSysClrTypes.msi – https://www.sqlazurelabs.com/SQLSysClrTypes.msi
3. SharedManagementObjects.msi – https://www.sqlazurelabs.com/SharedManagementObjects.msi
4. DACFramework.msi – https://www.sqlazurelabs.com/DACFramework.msi
5. SQLDom.msi – https://www.sqlazurelabs.com/SqlDom.msi
6. TSQLLanguageService.msi – https://www.sqlazurelabs.com/TSqlLanguageService.msi
After installing the prerequisites, extract the DacImportExportCli.zip to any directory ex. C:\DacImportExportCLI
-s – Server name
-d – Database name
-e – Integrated Authentication (For on-premise SQL Server)
-u – SQL User Name
-p – Password for SQL User name
-x – Export Schema and Data to bacpac file
-i – Import Schema and Data from bacpac file
-f – bacpac file , can be used as input and out based on –x or -i
-edition (Used for SQL Azure, Supported Values “business” or “web”)
-size – specify the Size of database in Gb ex. 1 (Used for SQL Azure to specify database size limit)
To Export Data and Schema
DacImportExportCli.exe –s ServerA.database.windows.net –d Northwind_DB –u dbuser –p password –f C:\DacImportExportCli\Northwind_DB_Backup.bacpac –x
To Import Data and Schema
DacImportExportCli.exe –s ServerB.database.windows.net –d Northwind_DB –u dbuser –p password –f C:\DacImportExportCli\Northwind_DB_Backup.bacpac –i
DacImportExportCli.exe –s ServerB.database.windows.net –d Northwind_DB –u dbuser –p password –f C:\DacImportExportCli\Northwind_DB_Backup.bacpac –i –edition web –size 1
To Remove a Database created using DAC Import
DacImportExportCli.exe –s ServerB.database.windows.net –drop Northwind_DB –u dbuser –p password
If you manually dropped a database using “DROP DATABASE” command for the database created using bacpac, the bacpac registration will still be available in server, you so you need to use –drop option to clear the registration, before reimporting it again
1. Helps automating backup and restore process for SQL Azure
2. Helps automatic synchronizing between SQL Azure and SQL Server (On Premise) easily
1. The exported bacpac file contains the schema and data, not the log files, so it’s a not a real backup like the regular SQL Server backup file
For more information about DAC read the below white paper http://msdn.microsoft.com/en-us/library/ff381683(SQL.100).aspx
Do not install this if you have already installed SQL Server “Denali” CTP1
12 thoughts on “DacImportExportCli : Import / Export Data from SQL Azure to SQL Server (vice versa)”
can DacImportExportCli be used for non-azure? e.g. sql server 2008?
Good Question !!! Yes, we can use it for SQL Server 2008 R2 and Denali.
I will test it on SQL Server 2005 and 2008 and post further information.
If you explain you exact scenario, I can test and explain you.
.\DacImportExportCli.exe -S ONE -E -I -D veodin_content_2 -F veodin_content_one.bacpac
Trying to import gives me an exception (I tried importing to my local SQL2008 and to Azure):
[15:56:31] CreateDatabase: Pending Creating database ‘veodin_content_2’
[15:56:31] CreateDatabase: Failure Creating database ‘veodin_content_2’ System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.SqlServer.BatchParser, Version=188.8.131.52, Culture=neutral, PublicKeyToken=89845
dcd8080cc91’ or one of its dependencies. The system cannot find the file specified.
File name: ‘Microsoft.SqlServer.BatchParser, Version=184.108.40.206, Culture=neutral, PublicKeyToken=89845dcd8080cc91’
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String query, ExecutionTypes executionType, Int32& statementsToReverse)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
Can you help?
Please download and install SQL Server 2008 R2 SP1 and also download the latest version of DACImportExportCLI from http://sqldacexamples.codeplex.com/releases/view/72388
First at all, thanks for your post. I’m trying to download the files from https://www.sqlazurelabs.com but I receive time out all the time… Do you know another site where I can download this msi’s?
Thanks a lot!
You can download the latest version from http://sqldacexamples.codeplex.com/
Hope this helps !!!
Never mind, I found it! 🙂 Thanks anyway ^^
Thanks so much for this article! I’ve downloaded all that is listed here (including updates to the downloads, so not actually what is “here”) and attempted to do this from a “remote” server…meaning a server other than my SQL server 2008 r2. I get an error:
Unhandled Exception: Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to connect to server . —> System.Data.SqlClient.SqlException:A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
Is is safe to assume that I need SQL client tools on my local server in order for it to reach the SQL server via the agent?
Thanks in advance!
Yes, you should have SQL Server Native Client Installed.
Based on your error message, I would suggest you to verify whether Remote connections are enabled in your SQL Server and also Firewall is configured to allow SQL Server Access
Hope this helps !!!
Thanks much again! I actually over cooked the problem. Decided to start at troubleshooting 101, and the ping to my SQL server didn’t work. 🙂 Resolved my DNS issue, and voila, all is right in the world, and the bacpac import worked like a charm.
So, I was just wondering if you might be aware of an option to import as an “upgrade”? I know, you can upgrade using a dacpac, but I want to upgrade using a bacpac, to also prefill any new data that my new version of the db requires. I see nowhere the ability to do this…but hoping maybe command line option, or someone might be aware of a new version in planning that will allow to upgrade from one data-tier version to a newer, to include new data also.
Thanks again, in advance!
Currently it doesn’t support creating a package with only new data, for implementing something like that you need to use Data Compare tools such as Red Gate Data Compare, xSQL Data Compare, Visual Studio 2010 Data Compare, etc…
Hope this clarifies your question !!!