Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP forum
Suggested answer

AP SQL script to look for orphaned records

Posted on by 75,730

Does anyone have a SQL script that will identify AP SQL script to look for orphaned records? I was using the AP Inquiry screen and noticed that several vendors cause this screen to crash. I suspect there are missing records in the AP tables.

  • Andrea Melroe Profile Picture
    Andrea Melroe 3,437 on at
    RE: AP SQL script to look for orphaned records

    Hi Richard,

    Glad to hear the problem is resolved!

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: AP SQL script to look for orphaned records

    I ran check links after deleting the records from the PM00400 table. The remaining problem was the next payment number in AP setup had not gotten updated so when they went to enter a new manual payment it tried to use an existing number.

  • Suggested answer
    Andrea Melroe Profile Picture
    Andrea Melroe 3,437 on at
    RE: AP SQL script to look for orphaned records

    Hi Richard,

    Here are some scripts I use to find invalid orphan records in payables:

    SELECT * FROM PM00400 WHERE (DCSTATUS = 0 OR DCSTATUS = '' OR DOCTYPE = '' OR DOCTYPE = 0 OR DOCNUMBR = '' OR CNTRLNUM = '' OR VENDORID = '') AND DCSTATUS <> 1

     

    SELECT * FROM PM10300 WHERE DOCTYPE = '' OR DOCTYPE = 0 OR VCHRNMBR= '' OR VENDORID = ''

     

    SELECT * FROM PM10400 WHERE DOCTYPE = '' OR DOCTYPE = 0 OR VCHRNMBR= '' OR VENDORID = '' OR DOCNUMBR = ''

     

    SELECT * FROM PM10100 WHERE VCHRNMBR = '' OR VENDORID = ''

     

    SELECT * FROM PM20000 WHERE DOCTYPE = '' OR DOCTYPE = 0 OR VCHRNMBR= '' OR VENDORID = '' OR DOCNUMBR = ''

     

    SELECT * FROM PM10200 WHERE DOCTYPE = '' OR DOCTYPE = 0 OR VCHRNMBR= '' OR VENDORID = '' OR APFRDCNM = '' OR APTODCNM = '' or APTVCHNM = ''

     

    SELECT * FROM PM30200 WHERE DOCTYPE = '' OR DOCTYPE = 0 OR VCHRNMBR= '' OR VENDORID = '' OR DOCNUMBR = ''

     

    SELECT * FROM PM30300 WHERE DOCTYPE = '' OR DOCTYPE = 0 OR VCHRNMBR= '' OR VENDORID = '' OR APFRDCNM = '' OR APTODCNM = '' or APTVCHNM = ''

     

    SELECT * FROM PM30600 WHERE VCHRNMBR = '' OR VENDORID = ''

    If there are records missing (like the PM00400 keys record – this is what I find is most commonly missing), it makes sense to run check links (in test) to let GP repopulate those for you.

    Hope this helps!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,556 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,625 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans