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 checks for corrupt data from the Extended Pricing tables; we had a client use the Table Import function and, unfortunately, imported some rows which did not have a price sheet id defined.
This script removes data from three tables:
- Extended Pricing Price Sheet Work (IV10401)
- Extended Pricing Price Sheet UofM Work (IV10402)
- Extended Pricing Price Sheet Work (IV10401)
/*
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).
*/
-- LINES WITHOUT HEADERS
SELECT
*
FROM
IV10401 AS ['Extended Pricing Price Sheet Work']
LEFT JOIN
SOP10110 AS ['Extended Pricing Price Sheet Header']
ON
['Extended Pricing Price Sheet Header'].PRCSHID = ['Extended Pricing Price Sheet Work'].PRCSHID
WHERE
['Extended Pricing Price Sheet Header'].PRCSHID IS NULL
GO
--PRICES WITHOUT LINES
SELECT
*
FROM
IV10402 AS ['Extended Pricing Price Sheet UofM Work']
LEFT JOIN
IV10401 AS ['Extended Pricing Price Sheet Work']
ON
['Extended Pricing Price Sheet Work'].PRCSHID = ['Extended Pricing Price Sheet UofM Work'].PRCSHID
AND
['Extended Pricing Price Sheet Work'].ITEMNMBR = ['Extended Pricing Price Sheet UofM Work'].ITEMNMBR
WHERE
['Extended Pricing Price Sheet Work'].PRCSHID IS NULL
GO
--LINES WITHOUT PRICES
SELECT
*
FROM
IV10401 AS ['Extended Pricing Price Sheet Work']
LEFT JOIN
SOP10110 AS ['Extended Pricing Price Sheet Header']
ON
['Extended Pricing Price Sheet Header'].PRCSHID = ['Extended Pricing Price Sheet Work'].PRCSHID
WHERE
['Extended Pricing Price Sheet Header'].PRCSHID IS NULL
GO