Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

SQL to show customers and vendors with no activity

Posted on by Microsoft Employee

Does anyone have an SQL query to show customer and vendors that have no activity? We have a number of customers and vendors who were setup in the wrong company in GP and should be removed. They have no history, transactions, etc., and will delete cleanly, but I don't have a good way to identify them. I was thinking and SQL script would be nice, but I'm not sure what tables I need to check against.


Thanks,


George

*This post is locked for comments

  • Verified answer
    Victoria Yudin Profile Picture
    Victoria Yudin 22,766 on at
    Re: SQL to show customers and vendors with no activity

    George,

    Part of the difficulty with this is that it depends on what modules you're using in GP.  Below is some sample code for finding customers that do not have any transactions in RM or SOP modules:

    select CUSTNMBR from RM00101 

    where CUSTNMBR not in (select CUSTNMBR from RM00401) -- this should capture all RM tables

    and CUSTNMBR not in (select CUSTNMBR from SOP30200) -- all SOP historical trx

    and CUSTNMBR not in (select CUSTNMBR from SOP10100) -- all SOP open trx

    if you think you need to check more modules/tables you can just add additional tests based on the example above.

    Similarly for vendors, if you are only using the PM module, you could use the following:

    select VENDORID from PM00200

    where VENDORID not in (select VENDORID from PM00400)

    If you need to check more modules, you would need to add additional tests.  

    For help with tables, you can check my blog, I have a list of the commonly used tables for the main modules: http://victoriayudin.com/gp-tables/.  You can also look for every table that has CUSTNMBR or VENDORID using this code: http://victoriayudin.com/2010/04/23/how-to-find-all-sql-tables-with-a-column-name/.  That may not be every table that has a customer or vendor ID, but for your purposes I believe it should suffice. 

    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans