3

Consider the following scenario:

  • We have a SSDT database project.
  • We add a new column to the middle of a table.
  • This forces the database project to rebuild the table in order to deploy the change.
  • We publish this SSDT database project with the setting “Block incremental deployment if data loss might occur” enabled.
  • Because we have the above setting enabled, and (also, I think) the table is being rebuilt the deployment (correctly) throws an error saying data loss may occur.

My question is this: Can we rely on the fact that whenever the table needs to be rebuilt as part of a SSDT publish this error will be thrown?

  • Are you adding a NOT NULL column? – Dan Guzman Feb 5 '15 at 13:26
  • No, I was adding a NULL column or a NOT NULL column with a DEFAULT. – jacobappleton Feb 5 '15 at 17:46
2

Yes, you can rely on that. When you enable the "BlockOnDataLoss" attribute what actually happens is that SSDT adds to the deployment script a check like this one

IF EXISTS(SELECT 1 FROM TableToChange)
BEGIN
     RAISEERROR ...
END

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.