I had an employee create a new Department for one Vendor. The employee named the department the vendor name. I want to merge these items into another existing department and then delete the vendor named department ( I know this will probably orphan some sales data, but that is okay). Can this be done through a sql command and if so could someone who knows these commands provide it?
Thanks,
Grier
*This post is locked for comments
Thank you for the script. I was also able to use the same logic for category by replacing department in your scripts. Worked like a champ.
Grier
Shouldn't be too difficult. As always, back up before executing any update statements.
You could definitely do this all at once with nested select statements, but I like to do updates in segments to ensure I'm not making any mistakes as I go. So, I'd run
SELECT ID FROM Department WHERE Name LIKE '%<incorrect name>%'
to get the incorrect department id, then
SELECT ID FROM Department WHERE Name LIKE '%<correct department>%'
to get the correct department id, then
UPDATE Item SET DepartmentID = '<value from statement 2>' WHERE DepartmentID = '<value from statement 1>'
The %'s are wildcard characters to avoid having to type the department name exactly how it appears in the database, which is a pain for some of our's, but if it's a simple name or if you have multiple departments that contain the same pattern of characters, you can just use the syntax "WHERE Name = '<name>'" instead.
The leftover department can be deleted from within RMS. If you're in a headquarters environment, be sure to issue the appropriate worksheets to push the changes down to the stores. And I don't think this should effect sales data, which is indexed by Item id, not department id. Hope this helps, and let me know if you have any questions.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,802 Super User 2024 Season 2
Martin Dráb 229,133 Most Valuable Professional
nmaenpaa 101,154