14

I have a dacpac that has set the BlockOnPossibleDataLoss set to false, however the deployment is blocked when I run it with sqlpackage.exe, telling me "The column [a] is being dropped, data loss could occur."

However when I use the exact same deployment profile and publish from Visual Studio 2012 it goes through.

Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323
nojetlag
  • 2,927
  • 9
  • 34
  • 42

3 Answers3

11

Have you tried executing sqlpackage.exe with /p:BlockOnPossibleDataLoss=false in the command line?

I just used SQLPackage.exe to create a .dacpac file of my test database, then I pubished it with the /p:BlockOnPossibleDataLoss=false option, and it overwrote my database.

Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323
3

I had the same issue and /p:BlockOnPossibleDataLoss=false don't work.

The final solution was in my case, that it also has to be set in the debug settings of the project file:

Project debug settings

Hope this helps someone! :)

3

Finally found the issue, I execute sqlpackage.exe within a powershell script where the error handling is set like

$Script:ErrorActionPreference = "Inquire"

since i never got the Inquire I assumed the problem was with sqlpackage.exe, however I had another powershell script included after the ErrorActionPreference was set, turned out the included script also had the ErrorActionPreference set, but to "Stop". Still I believe if I have set BlockOnPossibleDataLoss=false it should not result in an error, but at least I now have a way to handle it.

nojetlag
  • 2,927
  • 9
  • 34
  • 42