Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='ReleaseApr2024Week2'; 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 (OBJECT_ID('spGetConsumableCategories', 'P')) IS NOT NULL BEGIN DROP PROCEDURE spGetConsumableCategories END GO CREATE PROCEDURE spGetConsumableCategories AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT DISTINCT(Category) FROM vwProductCategory WHERE Product_Category_ID in (SELECT DISTINCT Product_Category_ID FROM Product WHERE Product_ID in (SELECT Product_ID FROM vwGetConsumables)) END GO IF (SELECT COUNT(0) FROM SystemSetting WHERE SettingKey = 'ProcessReversedIBT') = 0 BEGIN INSERT INTO SystemSetting(SettingKey, SettingCategoryId, SettingValueBit, TypeFlag) VALUES('ProcessReversedIBT', 1, 0, 4) END GO Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'ReleaseApr2024Week2'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO