Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='DecBulkUpdateOct14'; 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 @IsJV int; set @IsJV= (select default_value from System_Default where Default_Name = 'IsJV'); if @IsJV = 1 begin update DecBulkingPerc set Perc = 50 where StartDate = '2024-10-16' and EndDate = '2024-10-31' end; Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'DecBulkUpdateOct14'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO