How to import bacpac file to SQL database using command prompt

Requirement

How to import bacpac file to SQL database using command prompt.


High level resolution steps

  • Download the database backup from the Asset Library.
  • Import the database into the SQL.

Detailed resolution steps

Step 1 

By selecting the required database backup, we can download the bacpac file.


Step 2

Before importing the bacpac file to the sql, we are supposed to download the sql package. Net Core for Windows from  Get sqlpackage .NET Core for Windows.

Open a Command Prompt window and run the following commands from the sqlpackage .NET Core folder.

SqlPackage.exe /a:import /sf:“SourceFile” /tsn: “target server name” /tdn:< “target database name”> /p:CommandTimeout=1200 /TargetTrustServerCertificate:True

Note: Please make sure tsn (target server name) , tdn (target database name) & sf (source file) are mentioned in Double quotations.


Step 3 

Once the process is completed successfully, You can refresh the database.

You can find the imported database / bacpac file. Start to use the new database.


Blog written by   

Ramcharan Raj Pallavarapu | Dynamics 365 for Operations team.