I have a SQL Server database project in Visual Studio and I have dropped an existing stored procedure. I also have a database locally where that exact stored procedure exists.
When I run a schema compare from within Visual Studio on both, in the resulting schema compare window, I can see the stored procedure that will be dropped in the generated deployment script. However, when I invoke sqlPackage.exe from a Powershell script, the generated deployment script does not contain a drop statement for the stored procedure. Interestingly, when I make a change to the stored procedure, then it is included in the generated deployment script with an alter statement.
Why is sqlPackage.exe omitting the drop stored procedure statement when I remove it but including it for a change? I feel it's a parameter setting I need to feed to sqlPackage.exe but they seem to be opt out, not opt in (https://msdn.microsoft.com/library/hh550080(vs.103).aspx#Anchor_7).
Below is my command from Powershell:
& 'sqlPackage' '/Action:Script' "/SourceFile:$sourceDacpacFile" "/TargetFile:$targetDacpacFile" "/OutputPath:$outputPath" "/TargetDatabaseName:$targetDatabaseName" "/p:AllowIncompatiblePlatform=$allowIncompatiblePlatform" "/p:BlockOnPossibleDataLoss=$blockOnPossibleDataLoss" "/p:DropIndexesNotInSource=$dropIndexesNotInSource"
Take a look at the property DropObjectsNotInSource
Specifies whether objects that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publishto a database. This value takes precedence over DropExtendedProperties.
The default is False see: DacDeployOptions.DropObjectsNotInSource Property
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