Export and Import BACPAC files using SSMS

Jan 03, 2024

This guide describes how to export and import BACPAC files using Microsofts SQL Server Management Studio. Doing this is especially helpful to perform local backups or to setup a local development instance of an existing database.

Requirements

The following software must be present at your client machine:

Other requirements are:

Exporting a database

Exporting the database can be done using the UI of SSMS.

SSMS: Export Data-Tier Application
SSMS: Export Data-Tier Application
SSMS: Choose a filename for the bacpac export
SSMS: Choose a filename for the bacpac export

Import an existing bacpac file as a new database

SSMS: Import Data-Tier Application
SSMS: Import Data-Tier Application
SSMS: Choose bacpac file to import
SSMS: Choose bacpac file to import
SSMS: Specify new database name
SSMS: Specify new database name

Notes on Azure SQL Databases

When exporting an Azure SQL Database and trying to import it into a local SQL Server (e.g. running in docker-compose), you need to make sure that the “Enabled Contained Databases” setting is set to TRUE in your SQL Server properties. This is neccessary because Databases within Azure SQL PaaS are isolated using the “contained database” feature. Microsoft writes this:

A contained database is a database that is isolated from other databases and from the instance of SQL Server that hosts the database.

Microsoft Documentation

Experience shows, that this settings is by default off, at least for Linux container instances of MSSQL Server.

You can check if this feature is enabled by following these steps:

SSMS: Open server properties
SSMS: Open server properties
SSMS: Enable contained databases
SSMS: Enable contained databases

If you do not want to keep this setting enabled after import, you can change it back to FALSE as it is only needed for the import.

Sources

For further reading or more insights, here are the sources used for this guide.