Aug 18, 2014

SQL Script to Assign ALL ITEMS IN THE ITEM CLASS to a given Vendor in Microsoft GP

-------------------------------------------------------------------------  
-- Assign ALL ITEMS IN THE ITEM CLASS 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 ITMCLSCD IN ('CLASS ID 1','CLASS ID 2') -- REPLACE HERE TO ADD ITEM CLASS ID
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...

You have a very nice furniture writing style that i appreciate. bean bags are a great way to show your point and the furniture and chairs are very comfortable in the home. used laptops india