This script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.
This script created for a client who wanted to verify tax details on vendors in Dynamics GP against a spreadsheet. It uploads a tab delimited text file and outputs lines where the tax detail on the file is different to the one in the database.
/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
CREATE TABLE #Vendor
(
VENDORID VARCHAR(30)
,VENDNAME VARCHAR(100)
,ADDRESS1 VARCHAR(100)
,ADDRESS2 VARCHAR(100)
,CITY VARCHAR(100)
,STATE VARCHAR(100)
,ZIPCODE VARCHAR(100)
,PHONE1 VARCHAR(100)
,OLDTAXSCHID VARCHAR(30)
,BLANK VARCHAR(30)
,TAXSCHID VARCHAR(30)
,COMMENT VARCHAR(500)
)
GO
BULK INSERT
#Vendor
FROM
'c:\Temp\Vendors.txt'
WITH
(FIELDTERMINATOR = '\t'
,ROWTERMINATOR = '\n')
GO
SELECT
['PM Vendor Master'].VENDORID,*
FROM
#Vendor AS VendorUpdate
LEFT JOIN
PM00200 AS ['PM Vendor Master'] --PM Vendor Master File (PM00200)
ON
VendorUpdate.VENDORID = ['PM Vendor Master'].VENDORID
WHERE
['PM Vendor Master'].VENDORID IS NULL
OR
VendorUpdate.TAXSCHID <> ['PM Vendor Master'].TAXSCHID
GO
DROP TABLE #Vendor
GO