Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 2.91 KB

File metadata and controls

69 lines (49 loc) · 2.91 KB
title Export and import databases with SqlPackage - SQL Server vNext CTP1 | Microsoft Docs
description
author MikeRayMSFT
ms.author mikeray
manager jhubbard
ms.date 11/16/2016
ms.topic article
ms.prod sql-linux
ms.technology database-engine
ms.assetid 5befd8fa-a451-4cde-a6b9-121f20cc41ea

Export and import databases with SqlPackage

Use SqlPackage to create and deploy SQL Server databases and DACPAC packages. SqlPackage is a command-line utility for extraction and deployment of database snapshots and other data migration tasks. This tool makes use of the DACPAC format - a self-contained unit of SQL Server database deployment which allows the migration of data in a portable package.

SqlPackage location

SqlPackage can be found in an executable file that is in the following location:

/opt/mssql/bin/SqlPackage 

This file can be executed using the following pattern:

./SqlPackage /Action:{action} {parameters}  
./SqlPackage /Action:Extract /SourceServerName:localhost /SourceDatabaseName:your_database /TargetFile:"/path/to/your/file.dacpac" /SourceUser:"sa"

Use the following command to extract a DACPAC file from an existing database with SqlPackage

Use the following command to extract a DACPAC file from an existing database with SqlPackage:

./sqlpackage /Action:Extract /SourceServerName:"localhost/your_server" /SourceDatabaseName:"your_database" /SourceUser:"your_username" /SourcePassword:"your_password" /TargetFile:"/absolute/path/to/your/target/file.dacpac" 

Using the Extract action, you can provide the SourceServerName, SourceDatabaseName, SourceUser, and SourcePassword to connect and extract the DACPAC file to a local TargetFile.

Note: The "/p:Storage=Memory" option is the only one supported at this moment.

Extract a DACPAC file from an existing database into another database

Use the following command to extract a DACPAC file from an existing database and deploy it to another database server.

./sqlpackage /Action:Extract /SourceServerName:"localhost/your_server" /SourceDatabaseName:"your_database" /SourceUser:"your_username" /SourcePassword:"your_password" /TargetServerName:"target_server" /TargetDatabaseName:"target_database" /TargetUser:"target_username" /TargetPassword:"target_password" 

Using the Extract action, you can provide the SourceServerName, SourceDatabaseName, SourceUser, and SourcePassword to connect and extract the DACPAC file. Afterwards, SqlPackage will connect to a TargetServerName using the TargetDatabaseName, TargetUser, TargetPassword. Note: The "/p:Storage=Memory" option is the only one supported at this moment.

See also