Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='ReleaseSept2024Week4'; 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(1) from System_Default where Default_Name = 'Main_Store_ID' and Default_Value = '241') = 1 /*Junxion Mall*/ BEGIN IF (select count(1) from SystemSetting where SettingKey = 'CcwLaybySelectorSkip') = 0 BEGIN INSERT INTO SystemSetting (SettingKey, SettingCategoryId, SettingValueBit, TypeFlag) VALUES ('CcwLaybySelectorSkip', 1, 1, 4) END END IF (select count(1) from System_Default where Default_Name = 'Main_Store_ID' and Default_Value = '241') = 0 /*All other stores*/ BEGIN IF (select count(1) from SystemSetting where SettingKey = 'CcwLaybySelectorSkip') = 0 BEGIN INSERT INTO SystemSetting (SettingKey, SettingCategoryId, SettingValueBit, TypeFlag) VALUES ('CcwLaybySelectorSkip', 1, 0, 4) END END Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'ReleaseSept2024Week4'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO