Trying to use command for BACPAC

Billy 21 Reputation points
2020-12-11T02:30:31.917+00:00

I'm trying to setup a command to import a bacpac file, but have never done it before, and am a little stumped. The below command has username and password, but I use Windows Authentication. My end goal is to have access to the bacpac since we are transitioning applications, but am having issues.

sqlpackage.exe /a:import /tcs:"Data Source=<serverName>.database.windows.net;Initial Catalog=<migratedDatabase>;User Id=<userId>;Password=<password>" /sf:AdventureWorks2008R2.bacpac /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P6

Developer technologies Transact-SQL
SQL Server Other
{count} votes

Accepted answer
  1. Guoxiong 8,206 Reputation points
    2020-12-11T05:39:14.153+00:00

    Open Command Prompt as an administrator, and then try the following command:

    For SQL Server 2019:

    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150\SqlPackage.exe" /a:Import /sf:"[LOCATION]\AdventureWorks2008R2.bacpac" /tcs:"Data Source=[SERVER_NAME];Initial Catalog=[DATABASE_NAME]" /p:DatabaseEdition=Premium

    For SQL Server 2017 or previous version: (Note that 140 for SQL Server 2017, 130 for SQL Server 2016 ...)

    "C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /a:Import /sf:"[LOCATION]\AdventureWorks2008R2.bacpac" /tcs:"Data Source=[SERVER_NAME];Initial Catalog=[DATABASE_NAME]" /p:DatabaseEdition=Premium

    [SERVER_NAME] = Server name, i.e., localhost if your SQL server is on the current server
    [DATABASE_NAME] = Name of database you want to ccreate
    [LOCATION] = Directory where file .bacpac is located , i.e., C:\Test

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Cris Zhan-MSFT 6,661 Reputation points
    2020-12-11T08:27:56.233+00:00

    Hi @Billy ,

    If you want to import a BACPAC file to a database in Azure SQL Database using the SqlPackage with Active Directory Universal Authentication, you need to specify the /ua and /tid parameters in the command.

    This article provides directions for creating a new Azure SQL database from a BACPAC file using the Azure portal, PowerShell, SSMS, SqlPackage.
    https://github.com/uglide/azure-content/blob/master/articles/sql-database/sql-database-import.md

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.