web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics RMS (Archived)

Sql Script needed to set department and category

(0) ShareShare
ReportReport
Posted on by 782

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

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics RMS (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans