Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='SparesToExclusionListV2'; 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 not exists (select * from ReorderExclusionList where Product_Code = 'CDPLB15') begin Insert into reorderexclusionlist (Product_code,active) values ('CDPLB15',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'BMQ-01') begin Insert into reorderexclusionlist (Product_code,active) values ('BMQ-01',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'SW1501') begin Insert into reorderexclusionlist (Product_code,active) values ('SW1501',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'SWPLD15') begin Insert into reorderexclusionlist (Product_code,active) values ('SWPLD15',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'WPLB15') begin Insert into reorderexclusionlist (Product_code,active) values ('WPLB15',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'YW1020') begin Insert into reorderexclusionlist (Product_code,active) values ('YW1020',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'YW1230') begin Insert into reorderexclusionlist (Product_code,active) values ('YW1230',1) end Go if not exists (select * from ReorderExclusionList where Product_Code = 'YW1530') begin Insert into reorderexclusionlist (Product_code,active) values ('YW1530',1) end Go Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'SparesToExclusionListV2'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO