0

When I publish an SSDT project, as shown in the attached image, it generates the .dacpac file. From that .dacpac file, I want to execute a specific script after publishing the .dacpac. Is it possible to do so? I mean is it even possible to access that individual script file? If so, what is the way and which tool/command should I use in PowerShell?

PS: I know how to execute a .dacpac file against a database using a "SqlPackage.exe" and a "publish profile". I want to know a way to execute just an individual script, neither the tables nor the sprocs. Everything else works fine.

enter image description here

Mukesh Kumar
  • 656
  • 5
  • 26
  • 1
    Pre or Post deploy actions would be your best bet there, but remember that the compare against the schema is done _prior_ to that script being evaluated and run. But if you're looking for a solution to just run scripts, SSDT may not be the best option for you. You could wrap that in whatever is calling your SSDT publish action and run scripts that way if necessary - or make it a separate process. – Peter Schott Feb 25 '22 at 16:09
  • Thank you for your reply. I need to run the script after the .dacpac publish action. So, I think I have no choice but to run it after the post-deployment script. I didn't know how to execute a post-deployment script in SSDT, but then I found this youtube video that tells me exactly how to do it. https://youtu.be/49WIGMF1Sn0 – Mukesh Kumar Feb 26 '22 at 03:23
  • 1
    You add a script and set it's type to "Post-Deploy" and it will run after you do your publish. I usually make folders for Pre/Post deploy scripts to keep those separate from the schema scripts. IIRC, you only have one post-deploy script but you can use that to _call_ the other post-deploy scripts. https://schottsql.com/2012/11/01/ssdt-pre-and-post-deploy-scripts/ – Peter Schott Feb 27 '22 at 11:57

0 Answers0