How to publish DACPAC file to a SQL Server database project via SQLPackage.exe of SSDT?

Nam G VU picture Nam G VU · Dec 11, 2013 · Viewed 25.8k times · Source

I'm using SSDT for Visual Studio 2012 here and using its command-line tool SQLPackage.exe to publish a .dacpac file.

I want to publish that to an SQL Server database project. I'm trying to use parameter at this guide but cannot find ways how to do it.

How can I do that?

Answer

Kevin Cunnane picture Kevin Cunnane · Dec 11, 2013

Are you trying to publish to a Database, or create a database project from a dacpac? These are two different things.

  • To create a database project based on a dacpac, create a new SQL Server Database Project in Visual Studio. Then right-click on the project in Solution Explorer and choose "Import -> Data-tier Application (*.dacpac)" and select your dacpac. That will convert the contents of the dacpac into scripts in the project, and if you choose "Import database settings" the database options will be set based on the settings in the dacpac. Unfortunately there's no way to do this via a command line tool that I'm aware of.

  • To use SqlPackage.exe to publish to a database, the guide you linked to has all the options. A simple command would be "sqlpackage /a:publish /sf:db1.dacpac /tsn:localhost /tdn:db1" to publish dacpac "db1" to a database "localhost\db1". For other publish options type "sqlpackage /a:publish /?" to get the list of applicable actions on the command line.