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 populate the Extended Pricing Price Sheet Links (RM00500) table for price sheets after import through Table Import; it assigns all price sheets to all customers, unless the sheet is already assigned.
/*
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).
*/
INSERT INTO RM00500 --Extended Pricing Price Sheet Links (RM00500)
(
PRCSHID
,PRODTCOD
,LINKCODE
,SEQNUMBR
,PSSEQNUM
)
SELECT
['Extended Pricing Price Sheet Header'].PRCSHID
,'C'
,['Extended Pricing Price Sheet Header'].PRCSHID
,16384
,16384
FROM
SOP10110 AS ['Extended Pricing Price Sheet Header'] --Extended Pricing Price Sheet Header (SOP10110)
INNER JOIN
RM00101 AS ['RM Customer Master'] --RM Customer MSTR (RM00101)
ON
['RM Customer Master'].CUSTNMBR = ['Extended Pricing Price Sheet Header'].PRCSHID
WHERE
(
SELECT
COUNT(*)
FROM
RM00500 AS ['Extended Pricing Price Sheet Links'] --Extended Pricing Price Sheet Links (RM00500)
WHERE
['Extended Pricing Price Sheet Links'].PRODTCOD = 'C'
AND
['Extended Pricing Price Sheet Links'].LINKCODE = ['Extended Pricing Price Sheet Header'].PRCSHID
AND
['Extended Pricing Price Sheet Links'].SEQNUMBR = 16384
) = 0