0

I am currently using the following command to generate a database script using SSDT:

"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Script /sf:DB.dacpac /Profile:publish.xml /op:Script.sql

and the following command to publish:

"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish /sf:DB.dacpac /Profile:publish.xml 

Is there anyway we can merge them so it can generate a script (for audit purpose) as well as publish on the database?

developer
  • 1,401
  • 4
  • 28
  • 73

1 Answers1

3

Yes, it is quite recent but when you publish you can also use "/DeployScriptPath:" and give it a path and it will save the script.

Older versions of SSDT you had to do exactly what you are doing but we can now use this to do it in one step.

This will have the latest sqlpackage.exe in case you need it:

https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild/

ed

Ed Elliott
  • 6,666
  • 17
  • 32
  • Richie Lee has been working on a PS module, SSDTBuiltDeploy, that will pull these bits with nuget and then do much of the same as well using PS. Doing it all in once is a lot more convenient than needing to do two compares. :) https://github.com/RichieBzzzt/PoshSSDTBuildDeploy for the bits if you're interested. – Peter Schott Jul 23 '19 at 16:04