web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

SQL Scripts for Microsoft Dynamics GP: Update Site Descriptions From CSV

Ian Grieve Profile Picture Ian Grieve 22,784
Microsoft Dynamics GPThis 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

Read original post SQL Scripts for Microsoft Dynamics GP: Update Site Descriptions From CSV at azurecurve|Ramblings of an IT Professional


This was originally posted here.

Comments

*This post is locked for comments