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.
  • if operation logs is needed please add the below parameter to get the logs for the operation:


  • 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 (9)

  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.

  4. ctgarvey1 says:

    I keep getting, on export: “The target file argument must refer to a file with a ‘.dacpaq’ extension.” However .bacpaq is mentioned above.

    which is the correct extension name? dacpaq or bacpaq?

    1. ctgarvey1 says:

      Sorry I meant .dacpac or .bacpac !

      1. Hi Ctgarvey,
        DACPAC and BACPAC are similar but they target different scenarios. A DACPAC is focused on capturing and deploying schema, including upgrading an existing database. The primary use case for a DACPAC is to deploy a tightly defined schema to development, test, and then to production environments. And also the reverse: capturing production’s schema and applying it back to test and development environments.
        read more about it here:

Skip to main content