1

I am getting below error while executing DACPAC file using SQLPackage.

The column [dbo].[Temp].[GMTOffset] on table [dbo].[Temp] must be added, but the column has no default value and does not allow NULL values. If the table contains data, the ALTER script will not work. To avoid this issue you must either: add a default value to the column, mark it as allowing NULL values, or enable the generation of smart-defaults as a deployment option.

PowerShell script - & $using:SqlPackagePath /Action:Publish /tu:$using:DatabaseUsername /tp:$using:DatabasePassword /tsn:$using:ServerInstance /tdn:"$_" /sf:$using:DacpacLocation /p:BlockOnPossibleDataLoss=False

I have set 'Generate smart defaults, when applicable' setting in publish profile of the DB project and execute the PowerShell script after compiling the project, however, still getting this error. Any pointers or help would be appreciated.

user13624867
  • 225
  • 4
  • 14
  • 1
    It might be that your GMTOffset is a type that doesn't support a smart default. What happens if you add an actual default constraint? What if you specify the option on the command line to use smart defaults? Where is your option on the command line to use the publish profile? I don't see that in your example above. – Peter Schott Oct 06 '20 at 13:21
  • yes, I was able to resolve this error after specifying this option on the command line. – user13624867 Oct 06 '20 at 13:29

1 Answers1

0

This error was resolved after specifying this option on the command line like below as @Peter also mentioned.

& $using:SqlPackagePath /Action:Publish /tu:$using:DatabaseUsername /tp:$using:DatabasePassword /tsn:$using:ServerInstance /tdn:"$_" /sf:$using:DacpacLocation /p:GenerateSmartDefaults=True /p:BlockOnPossibleDataLoss=False

user13624867
  • 225
  • 4
  • 14