Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlPackage.exe not including dropped stored procedure in deployment script

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"
like image 719
dhughes Avatar asked Mar 11 '23 11:03

dhughes


1 Answers

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

like image 135
David Martin Avatar answered Mar 13 '23 00:03

David Martin