Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='TinMoneyUpdate10042025'; if @@ROWCOUNT!=0 BEGIN RAISERROR('THIS SCRIPT HAS ALREADY BEEN RUN ON THIS SERVER, CANNOT CONTINUE, PLEASE CONTACT DEV',11,1); RETURN; END GO insert into Product_Catalogue_History select Product_Catalogue_ID, GETDATE(), Product_Catalogue_Status_ID, 'Script Update: Status set to active' from Product_Catalogue where product_id in (select Product_ID from product where Product_Code in ('17-3446A', '17-3446B')) update Product_Catalogue set Product_Catalogue_Status_ID = 1, Last_Catalogue_Status_ID = 2, Last_Catalogue_Changed = GETDATE(), Last_Change_Reason = 'Script Update: Status set to active' where Product_ID in (select Product_ID from product where Product_Code in ('17-3446A', '17-3446B')) and Product_Catalogue_Status_ID = 2 go Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'TinMoneyUpdate10042025'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO