5

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".

1
  • you might want to ask this question on dba.stackexchange.com Commented Jun 19, 2014 at 1:14

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

it sounds like you're doing the right thing, and it should work.

if i had to guess, i'd say:

  • you may be ignoring errors (:on error ignore somewhere in your project? sqlserver or your environment are configured to treat errors as warnings and ignore them?)
  • you may not actually be throwing the errors - can you post a sample script somewhere for us to see?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.