Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics RMS (Archived)

Sql Script needed to set department and category

Posted on by 780

Can somebody help me. I need a sql script that will assign the department to all items from a supplier. The issue is that a duplicate department and some duplicate categories were created and these were deleted and now I have certain suppliers with all of their items without departments or categories. I'm hoping that there is a way to write a sql command that would assign the department to all items for a particular supplier, the same for category.

Thanks,

Grier 

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sql Script needed to set department and category

    use:  Select * from [supplier]

    and record the value in the ID column.

    use: Select * from [department]

    and:   Select * from [category]

    record the ID columns for any you might need.   For the categories take not of the departmentID also.  Do not cross update an item, for example the category has a departmentID of 2 and you update the Item to that category but enter a categoryID of 3.  This will cause you problems.

    This will work for items and their Primary Supplier.  If you need secondary supplier then this gets way more complicated.

    Then use the following to update.

    Update [Item]  set DapartmentID = {ID you recorded - replace{} also}, set CategoryID = {category id here, replace everything including {} here} where supplierID = {same as before, replace with Supplier ID number}

    so it should look something like this:

    Update [Item} set DepartmentID = 2, set CategoryID = 5 where SupplierID = 10

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans