Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='GoldVatSADC17032025'; 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 (7,8,192,245,252,157,188,200,225,268,284,315,122)) begin update SystemSetting set SettingValueString = '' where SettingKey = 'VatExemptedCategories'; end Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'GoldVatSADC17032025'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO