Print 'Doing pre run Checks to ensure script not already run'; Select * from Script_History where Script_Name='AddDMXStock28022025'; 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 @StoreId int; set @StoreId = (select default_value from system_default where Default_Name = 'Main_store_id'); If(@StoreId in (164,90,43,27,76,262,26,106,131,162,127,251,96,110,118,126,120)) begin update systemsetting set settingvaluebit = 1 where settingkey = 'gpminimums'; end; If(@StoreId in (1,13,26,27,28,29,34,36,39,42,43,45,47,49,52,53,55,57,59,60,63,64,65,66,73,74,76,79,81,89,90,91,95,96,98,99,103,105,106,108,110,112,114,118,120,126,127,130,131,137,140,141,144,145,154,157,159,161,162,163,164,166,176,180,194,198,201,206,207,210,211,212,213,217,218,223,224,226,229,230,232,233,235,236,237,238,241,244,247,248,249,250,251,254,255,256,257,258,259,260,261,262,264,266,267,268,269,270,272,273,274,279,280,281,282,283,284,285,286,287,288,290,291,292,293,294,295,297,298,299,301,303,304,305,307,308,309,310,311,312,313,314)) begin if((select count(0) from Product_Brand where Description = 'mecer') = 0) begin insert into Product_Brand(Description,Approved) values('Mecer',1); end if((select count(0) from Product_Brand where Description = 'Samsung') = 0) begin insert into Product_Brand(Description,Approved) values('Samsung',1); end if((select count(0) from Product_Brand where Description = 'Dixon') = 0) begin insert into Product_Brand(Description,Approved) values('Dixon',1); end if((select count(0) from Product where Product_Code = 'DMXSamsung55HQ') = 0) begin insert into product (Product_Code,Product_Category_ID,Product_Brand_ID,Description,New_Warranty_Period_ID,[2nd_warranty_period_id],Last_Par_Level ,store_id,ForHQReview,Created,System_User_ID,InstantExchange,SerialRequired) values('DMXSamsung55HQ',(select product_category_id from product_category where Master_Category_ID = 4105),(select top 1 Product_Brand_id from Product_Brand where Description ='Samsung'), 'Samsung 55 inch panel',5,7,0,0,0,GETDATE(),2,0,1); end; if((select count(0) from Product where Product_Code = 'DMXMecer55HQ') = 0) begin insert into product (Product_Code,Product_Category_ID,Product_Brand_ID,Description,New_Warranty_Period_ID,[2nd_warranty_period_id],Last_Par_Level ,store_id,ForHQReview,Created,System_User_ID,InstantExchange,SerialRequired) values('DMXMecer55HQ',(select product_category_id from product_category where Master_Category_ID = 4105),(select top 1 Product_Brand_id from Product_Brand where Description ='Mecer'), 'Mecer 55 inch panel',5,7,0,0,0,GETDATE(),2,0,1); end; if((select count(0) from Product where Product_Code = 'DMXDixon55HQ') = 0) begin insert into product (Product_Code,Product_Category_ID,Product_Brand_ID,Description,New_Warranty_Period_ID,[2nd_warranty_period_id],Last_Par_Level ,store_id,ForHQReview,Created,System_User_ID,InstantExchange,SerialRequired) values('DMXDixon55HQ',(select product_category_id from product_category where Master_Category_ID = 4105),(select top 1 Product_Brand_id from Product_Brand where Description ='Dixon'), 'Dixon 55 inch panel',5,7,0,0,0,GETDATE(),2,0,1); end; if((select count(0) from Stock_Item where stock_code = '100DMXSAMS') = 0) begin insert into stock_item (Item_Description,Product_ID,Stock_Code,Item_Stock_Type_ID,Serial_Number,Unit_Cost,Stock_Holding_Group_ID,Target_Release_Date,Source_Contract,Vat,Is_Cost_Price_Inclusive,Original_Purchase_Date,Store_ID) values ('Samsung 55 inch panel',(select top 1 product_id from product where Product_Code = 'DMXSamsung55HQ'),'100DMXSAMS',1,'',0.10,2,GETDATE(),'DMX update',0,1,'2025-02-28',1); end; if((select count(0) from Stock_Item where stock_code = '100DMXMECE') = 0) begin insert into stock_item (Item_Description,Product_ID,Stock_Code,Item_Stock_Type_ID,Serial_Number,Unit_Cost,Stock_Holding_Group_ID,Target_Release_Date,Source_Contract,Vat,Is_Cost_Price_Inclusive,Original_Purchase_Date,Store_ID) values ('Mecer 55 inch panel',(select top 1 product_id from product where Product_Code = 'DMXMecer55HQ'),'100DMXMECE',1,'',0.10,2,GETDATE(),'DMX update',0,1,'2025-02-28',1); end; if((select count(0) from Stock_Item where stock_code = '100DMXDIX') = 0) begin insert into stock_item (Item_Description,Product_ID,Stock_Code,Item_Stock_Type_ID,Serial_Number,Unit_Cost,Stock_Holding_Group_ID,Target_Release_Date,Source_Contract,Vat,Is_Cost_Price_Inclusive,Original_Purchase_Date,Store_ID) values ('Dixon 55 inch panel',(select top 1 product_id from product where Product_Code = 'DMXDixon55HQ'),'100DMXDIX',1,'',0.10,2,GETDATE(),'DMX update',0,1,'2025-02-28',1); end; if((select count(0) from Pricing where Stock_Item_ID in (select Stock_Item_ID from stock_item where stock_code = '100DMXSAMS')) = 0) begin insert into Pricing(From_Date,To_Date,RRP,Product_ID,System_User_ID,Stock_Item_ID,Store_ID,RRP_VAT) values('2025-03-01','2025-05-31',4999, (select top 1 Product_ID from Product where Product_Code = 'DMXSamsung55HQ'), 2, (select top 1 Stock_Item_Id from Stock_Item where Stock_Code = '100DMXSAMS'),1,652.04); end; if((select count(0) from Pricing where Stock_Item_ID in (select Stock_Item_ID from stock_item where stock_code = '100DMXMECE')) = 0) begin insert into Pricing(From_Date,To_Date,RRP,Product_ID,System_User_ID,Stock_Item_ID,Store_ID,RRP_VAT) values('2025-03-01','2025-05-31',3999, (select top 1 Product_ID from Product where Product_Code = 'DMXMecer55HQ'), 2, (select top 1 Stock_Item_Id from Stock_Item where Stock_Code = '100DMXMECE'),1,521.61); end; if((select count(0) from Pricing where Stock_Item_ID in (select Stock_Item_ID from stock_item where stock_code = '100DMXDIX')) = 0) begin insert into Pricing(From_Date,To_Date,RRP,Product_ID,System_User_ID,Stock_Item_ID,Store_ID,RRP_VAT) values('2025-03-01','2025-05-31',2999, (select top 1 Product_ID from Product where Product_Code = 'DMXDixon55HQ'), 2, (select top 1 Stock_Item_Id from Stock_Item where Stock_Code = '100DMXDIX'),1,391.17); end; If (@StoreId=290 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=285 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=284 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=281 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=280 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=279 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=274 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=270 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=269 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=267 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=266 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=236 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,1,@StoreId); end If (@StoreId=217 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=213 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,1,@StoreId); end If (@StoreId=194 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=154 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=140 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,1,@StoreId); end If (@StoreId=73 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=34 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXSAMS'),2,2,@StoreId); end If (@StoreId=313 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=312 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=311 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=310 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=309 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=308 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=307 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=305 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=304 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=303 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=301 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=298 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=297 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=295 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=294 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=293 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=292 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=291 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=288 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=287 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=286 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=273 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=272 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=268 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=264 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=261 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=260 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=259 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=258 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=257 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=256 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=250 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=249 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=247 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=244 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=241 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=238 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=237 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=235 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=232 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=230 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=229 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=226 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=224 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=223 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=218 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=213 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=212 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=211 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=210 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=201 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=180 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=176 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=163 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=161 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=159 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=144 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=141 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=130 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=118 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=114 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=112 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=105 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=103 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=99 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=95 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=91 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=89 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=81 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=79 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=74 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=66 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=65 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=64 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=63 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=60 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=59 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=55 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=53 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=52 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=47 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=45 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=39 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=36 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=29 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=28 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,2,@StoreId); end If (@StoreId=13 ) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXMECE'),2,1,@StoreId); end If (@StoreId=314) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=286) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=283) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=282) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=262) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=259) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=255) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=254) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=250) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=249) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=248) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=233) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=223) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=212) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=211) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=207) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,3,@StoreId); end If (@StoreId=206) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=201) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=198) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=166) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=164) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=162) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=157) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=145) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=141) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=140) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=137) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=127) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=120) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=114) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=106) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=103) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=99) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=98) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=96) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=90) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=79) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=76) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=57) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=49) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=43) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=39) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=26) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end If (@StoreId=13) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,1,@StoreId); end If (@StoreId=1) begin insert into stock_item_count (stock_item_id,Stock_holding_group_id,Stock_Count,Store_Id) values ((select top 1 stock_item_id from stock_item where stock_code = '100DMXDIX'),2,2,@StoreId); end end Print 'Insert into script history if everything else is cool'; Insert into Script_History (RunDate,Script_Name) Values (CURRENT_TIMESTAMP,'AddDMXStock28022025'); IF @@ERROR != 0 BEGIN RAISERROR ('UNABLE TO CONTINUE WITH SCRIPT', 11, 1); RETURN; END GO