Print 'Doing pre run Checks to ensure script not already run'; SELECT * FROM Script_History WHERE Script_Name='ProjectionUpdate20241014'; IF @@ROWCOUNT!=0 BEGIN RAISERROR('THIS SCRIPT HAS ALREADY BEEN RUN ON THIS SERVER, CANNOT CONTINUE, PLEASE CONTACT DEV',11,1); RETURN; END GO IF (SELECT count(0) FROM System_Default WHERE Default_Name = 'Main_Store_ID' AND Default_Value IN (10,237,89,157)) > 0 UPDATE SystemSetting SET SettingValueDecimal = '5' WHERE SettingKey = 'ProjectionPeriod GO Print 'If you see rows affected means it updated and ran script if you just see this message means nothing was updated'; GO IF (SELECT count(0) FROM System_Default WHERE Default_Name = 'Main_Store_ID' AND Default_Value IN (10,237,89,157)) > 0 UPDATE SystemSetting SET SettingValueBit = False WHERE SettingKey = 'ProjectionPeriodEnabled' GO Print 'Insert into script history if everything else is cool'; INSERT INTO Script_History (RunDate,Script_Name) VALUES (CURRENT_TIMESTAMP,'ProjectionUpdate20241014'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO