Using SQLPackage to import or export SQL Server and Azure SQL DB


Explain how to easily and quickly use SQLPackage to import or export your SQL Server and Azure SQL Database.

Locating the SQLPackage.exe:

The SQLPackage.exe is part of the DacFramework which installed with SSMS or with SQL Server Data Tools

Or you can download only the DacFramework if you do not have already the management tools

Once the DacFramework / SSMS / SSDT is installed you can locate the SQLPackage.exe in this path

C:\Program Files (x86)\Microsoft SQL Server\<Version>\DAC\bin

* Change the version to match the installed version. (120-SQL2014, 130-SQL2016, 140-Recent)

* Change the drive letter if you installed it to a different location

Export from Azure SQL DB to bacpac file:

to export database from your Azure SQL DB to bacpac file use this command:

sqlpackage.exe /Action:Export /ssn:tcp:<ServerName>,1433 /sdn:<DatabaseName> /su:<UserName> /sp:<Password> /tf:<TargetFile> /p:Storage=File


sqlpackage.exe /Action:Export /,1433 /sdn:AdventureWorks /su:AdminUser /sp:AdminPassword1 /tf:C:\Temp\AW.bacpac /p:Storage=File

Import from bacpac file to Azure SQL DB:

to import database from bacpac file to your Azure SQL DB use this command:

sqlpackage.exe /Action:Import /tsn:tcp:<ServerName>,1433 /tdn:<TargetDatabaseName> /tu:<UserName> /tp:<Password> /sf:<Path to bacpac file> /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P4 /p:Storage=File


import database to default target service tier S0:

sqlpackage.exe /Action:Import /,1433 /tdn:AdventureWorks /tu:AdminUser /tp:AdminPassword1 /sf:C:\temp\AW.bacpac /p:Storage=File

import database and set target service tier to P2

sqlpackage.exe /Action:Import /,1433 /tdn:AdventureWorks /tu:AdminUser /tp:AdminPassword1 /sf:C:\temp\AW.bacpac /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P2 /p:Storage=File


  • /p:Storage=File : is used to redirect the backing storage for the schema model used during extraction, this helpful with large databases that may cause out-of-memory exception if the default memory location is used.
  • Note that for large databases its recommended setting the service tier during the import, this help import process to run faster.
  • When exporting from the active database, the database may not be transactional consistent as this process go object by object. If transactional consistent is needed it's recommended to export from the copied database. (learn how to copy Azure SQL DB)

    (thanks to ErikEJ for his comment)

Full documentation for SQLPackage.exe

Comments (6)

  1. ErikEJ says:

    Note that sqlpackage does not export a transactionally consistent package, so a good approach is to extract from a database copy.

    1. Aman [MSFT] says:

      Absolutely correct, I added that to the head of the post. thanks!

  2. pini Krisher says:

    What is the size limit of DB can be?

    1. Aman [MSFT] says:

      can you be more specific?

  3. Josh says:

    What is the switch to have it ignore users and logins? The ones I found for SQLPackage do not apply to Export

    1. Hi Josh, there is no option to exclude logins or users during export.

Skip to main content