Reputation: 21224
Is there a way to import a BACPAC file into an existing (empty) database? It looks like the PowerShell commands allow me to create new target databases only...
Is there a trick?
Upvotes: 5
Views: 4329
Reputation: 1029
Yes you can import BACPAC file to an existing db but it should be absolutely empty.
Use below command, run it from cmd or powershell. Note : location of sqlpackage.exe could be different on your machine.
/tdn: is target database name here, which could be a pre-existing db but totaly empty. It's a good practice to create db before hand for larger db imports. SQL package.exe does make a new db for you if your db does not exists but then it caps its maximum size to 32gb unless specified otherwise.
c:\"Program Files"\"Microsoft SQL Server"\150\DAC\bin\sqlpackage.exe
/a:Import
/sf:"bacpac file path"
/tsn:"targetsqlserver.database.windows.net"
/tdn:target_database_name
/tu:username
/tp:password
Upvotes: 10
Reputation: 15694
It is not possible to import or restore a bacpac to an existing Azure SQL Database. It will always create a new database.
Drop the existing database and rename the database resulting from the imported bacpac, or drop the database and import the bacpac using as database name the name of the dropped database.
Upvotes: 4