9 Oct 2014

Publish/Script Database using SqlPackage.exe command with quick useful parameters - SQL Server Data Tools

For publish

"C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /Action:Publish /SourceFile:"C:\Source\Database\bin\Debug\database.dacpac" /TargetConnectionString:"Data Source=DataServers;Integrated Security=False;Initial Catalog=DatabaseName;User ID=UserName;Password=pwd;" /v:= /v:= /p:DropObjectsNotInSource=False /p:BlockOnPossibleDataLoss=True

For generating script instead of publish

"C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /Action:Publish /SourceFile:"C:\Source\Database\bin\Debug\database.dacpac" /TargetConnectionString:"Data Source=DataServers;Integrated Security=False;Initial Catalog=DatabaseName;User ID=UserName;Password=pwd;" /v:= /v:= /p:DropObjectsNotInSource=False /p:BlockOnPossibleDataLoss=True /OutputPath:"C:\Deploy.sql"

2 comments:

  1. Nice! This is definitely useful in automation...

    ReplyDelete
  2. I guess the second example is /Action:Script instead of /Action:Publish.

    ReplyDelete