Aug 18, 2014

SQL Script to Assign SPECIFIC Items to a given Vendor in Microsoft GP

--------------------------------------------------------  
-- Assign SPECIFIC Items to a given Vendor     
-- Code by Venugopal G A     
-- mail me for any queries venuasg@gmail.com
-- Change the vendor variable to your vendorid     
--------------------------------------------------------    
DECLARE @VENDORID VARCHAR(15)
DECLARE @ITEM VARCHAR(100)
DECLARE @ITEMDESC VARCHAR(100)
SET @VENDORID = 'ACETRAVE0001' -- CHANGE TO YOUR VENDOR ID

DECLARE ITEMMASTER CURSOR FOR 
SELECT ITEMNMBR, ITEMDESC  FROM IV00101 WHERE ITEMNMBR IN ('ITEM1','ITEM2','ITEM3') -- REPLACE HERE TO ADD ITEMS
OPEN ITEMMASTER
 FETCH NEXT FROM ITEMMASTER INTO @ITEM, @ITEMDESC
 WHILE (@@fetch_status <> -1) 
            BEGIN
  INSERT INTO [IV00103] ([ITEMNMBR],[VENDORID],[ITMVNDTY],[VNDITNUM],[VNDITDSC])
  VALUES(@ITEM,@VENDORID,1,@ITEM,@ITEMDESC)
            
  FETCH NEXT FROM ITEMMASTER INTO @ITEM, @ITEMDESC
            END
CLOSE ITEMMASTER    
DEALLOCATE ITEMMASTER

1 comment:

albina N muro said...

I think it would. But I'm also just maybe Realizing That I Already have enough fun in my life! it asset disposition services