I'm working to deploy SQLProj (Database Project) via VS2013 and I'm encountering an issue that I could use some feedback on.
When I publish changes it executes a CCRD (Create, Copy, Rename, Delete) operation for a table. Create and Copy in the PreDeploy script and the Rename, Delete in the PostDeploy Scripts. I have these statements encapsulated in a Try...Catch block and have it printing out error messages. When the Pre and Post deploy scripts encounter issues the publish completes showing the publish as successful. I'm needing the behavior to be different when these scripts encounter errors. I would like for any errors encountered within these scripts cause the publish to fail. I've tried the THROW command to throw an error and I've tried the RAISERROR command setting severity to 20 when it's executed, which according to BOL should terminate the connection, but still the publish completes with a status of "Successful".
Something we have done is split the process. We use SQLPackage.exe with the script action. Then we use SQLCMD.exe to execute the script. That way you have ONE script that contains your pre/main/post and using SQLCMD will stop execution when errors occur.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With