Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Temporal History Retention in Visual Studio SQL Server 2017 Database Project

Is there any way to set the database option for Temporal History Retention to off in a Visual Studio SQL Server 2017 Database project?

When I generate a script from my publish profile it adds the code below and I'm unable to find a way to prevent it.

ALTER DATABASE [$(DatabaseName)]
    SET TEMPORAL_HISTORY_RETENTION ON 
    WITH ROLLBACK IMMEDIATE;

I don't want to prevent it from setting all db options as I do use others. I only want to set this one to OFF so the script doesn't produce the output above.

  • Visual Studio Version - Professional 2019 (16.4.5)
  • SQL Server Data Tools - 16.0.62002.03150
  • SQL Server Version - 2017 (14.0.3223.3)

I feel like i'm just missing a tick box somewhere?!?

Any help would be very much appreciated.

like image 348
alexs Avatar asked Jan 21 '26 05:01

alexs


1 Answers

Edit the .sqlproj file and add either True or False for the TemporalHistoryRetentionEnabled param.

i.e. <TemporalHistoryRetentionEnabled>True</TemporalHistoryRetentionEnabled>

Edit: it seems to be a bug when importing a database/dacpac the option is set to On/Off depending on whether or not you choose to import database settings.

like image 67
BT93 Avatar answered Jan 23 '26 08:01

BT93



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!