Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 53207

Insert Inventory User Categories From CSV

$
0
0

Microsoft Dynamics GPI have had this script for quite a while and have used it a number of times for different clients when implementing the Inventory Control module in Microsoft Dynamics GP.

One client who was using Inventory was entering a lot of user categories, mistakenly entered the description into the Image field. In that case I did not know that they were populating the User Categories or I would have offered this script to them to save time.

To use the script you need a CSV file with four columns: User Category Value (the ID of the item you want to load), User Category Number (which of the user categories into which the row is to be loaded), Image URL and Description:

CREATE TABLE #UploadData(USCATVAL VARCHAR(100),USCATNUM VARCHAR(1),Image_URL VARCHAR(300),UserCatLongDescr VARCHAR(300))GOBULK INSERT
	#UploadDataFROM'c:\temp\UserCategories.csv'WITH(FIELDTERMINATOR=',',ROWTERMINATOR='\n')GOINSERT INTO IV40600(USCATVAL,USCATNUM,Image_URL,UserCatLongDescr)(SELECTLEFT(UD.USCATVAL, 10),LEFT(UD.USCATNUM, 1),LEFT(UD.Image_URL, 254),LEFT(UD.UserCatLongDescr, 254)FROM
		#UploadData AS UDWHERE(SELECTCOUNT(IV.USCATVAL)FROM
			IV40600 AS IVWHERE
			IV.USCATVAL = UD.USCATVAL
		AND
			IV.USCATNUM = UD.USCATNUM)= 0)GODROP TABLE #UploadDataGO

You will need to change the highlighted line to the location of your CSV file. As always before running a script on live, test it in a test company first and have a good backup of your database.


Viewing all articles
Browse latest Browse all 53207


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>