This script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.
This script was created to allow a client to rename sites in Dynamics GP from a CSV file.
If the name provided was only DO NOT USE then this was added to the start of the existing site description (which was then truncated to the maximum length of 30 characters) otherwise the site description was replaced with the one from the file.
/*
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 #Sites
(
LOCNCODE VARCHAR(10)
,LOCNDESC VARCHAR(30)
)
GO
BULK INSERT
#Sites
FROM
'C:\Temp\Site Descriptions.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
UPDATE
IV
SET
IV.LOCNDSCR = (
CASE WHEN Sites.LOCNDESC = 'DO NOT USE' THEN
LEFT(RTRIM(Sites.LOCNDESC) + ' - ' + RTRIM(IV.LOCNDSCR),30)
ELSE
RTRIM(Sites.LOCNDESC)
END
)
FROM
IV40700 IV
INNER JOIN
#Sites As Sites
ON
Sites.LOCNCODE = IV.LOCNCODE
GO
DROP TABLE #Sites
GO
Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index
What should we write about next?
If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.
Looking for support or consultancy with Microsoft Dynamics GP?
I no longer work with Microsoft Dynamics GP, but the last company I worked for was ISC Software in the UK; if you’re looking for support or consultancy services with Microsoft Dynamics GP you can contact them here.