Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

RMS SQL Query Help

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I need to make some items inactive and would like to do it via an sql query. I have items that relates to each other with the Itemlookupcode for example of 20-1234 and 20-1234LG (which is a fixed length of item 20-1234).  So I want to make sure both items equal 0 before making them, both inactive. Since someone my buy the item 20-1234LG and ask us the order more - so we would need the item 20-1234 as active.

Logic ( I hope this make sense:

Loop

If ItemLookupcode where Quantity = 0 AND

itemlookupcode+LG as ILCLG where Quantity = 0

Set inactive both Itemlookupcode and ILCLG

Any help would be appreciated.

Dan

 

*This post is locked for comments

  • Suggested answer
    TimB Profile Picture
    TimB 1,175 on at
    Re: RMS SQL Query Help

    Matt's queries will work just fine. To see which records will be affected you can first run this query.

    select i1.itemlookupcode,i1.description,i2.itemlookupcode,i2.description from item i1 join item i2

    on i1.itemlookupcode=i2.itemlookupcode+'lg'

    where i1.quantity=0 and i2.quantity=0

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: RMS SQL Query Help

    Try this:

    update i1 set i1.inactive=1 from item i1 join item i2
    on i1.itemlookupcode=i2.itemlookupcode+'lg'
    where i1.quantity=0 and i2.quantity=0

    update i2 set i2.inactive=1 from item i1 join item i2
    on i1.itemlookupcode=i2.itemlookupcode+'lg'
    where i1.quantity=0 and i2.quantity=0

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!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans