Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='FACGoodReturnIssueFixv3'; if @@ROWCOUNT!=0 BEGIN RAISERROR('THIS SCRIPT HAS ALREADY BEEN RUN ON THIS SERVER, CANNOT CONTINUE, PLEASE CONTACT DEV',11,1); RETURN; END GO declare @StoreId int; set @StoreId = (select default_value from system_default where Default_Name = 'Main_store_id'); If(@StoreId in (2,3,6,17,24,25,26,27,38,41,50,54,62,67,68,69,70,75,76,82,85,86,90,93,96,100,106,110,111,113,118,121,124,126,127,128,129,131,135,142,146,149,150,155,156,158,162,164,165,173,174,177,182,183,185,199,215,219,220,227,242,246,251,262,276)) begin update pricing set to_date = dateadd(MONTH,1,From_Date) where to_date >'2024-12-31'; update Sales_Transaction_Line set cost_vat = (Unit_Cost - (Unit_Cost /1.15)) where cost_vat is null and Sales_Transaction_ID in ( select Sales_Transaction_ID from Sales_Transaction where Completed > '2023-11-16' ); update Promotion set Period_Start = '2024-09-01', Period_End = '2024-09-30' where Promotion_ID >= 281; update SystemSetting set SettingValueBit = 0 where SettingKey = 'PromoAutomationActivated'; update SystemSetting set SettingValueDecimal = '0.00' where SettingKey = 'StandardAvailability'; Update SystemSetting set SettingValueDecimal = '0.00' where SettingKey = 'KeylineAvailability'; update SystemSetting set SettingValueDecimal = '0.00' where SettingKey = 'PromoAvailability'; update SystemSetting set SettingValueBit = 0 where SettingKey in ('ReorderBulkingPeriod','IsBulkingSeason'); update SystemSetting set SettingValueBit = 0 where SettingKey = 'FIC'; end Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'FACGoodReturnIssueFixv3'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO