Search and replace departments

Apr 02, 2008 1 Replies

I have a client that currently has 900 departments that they would like consolidated to 21 deparments (carryover from old POS system). So I've been using the following SQL query to do this task: UPDATE ITEM SET Departmentid=(new ID) WHERE Departmentid=(old ID)



Is there a faster way to do this?



Thanks in advance. Phil


Hi Phil - maybe you can use "IN"....lets say department IDs 1, 2, 3, 4, 5, 8

9, 11, and 15 should now be assigned to dept id 23....

update item set departmentid = 23 where departmentid in (1, 2, 3, 4, 5, 8 9, 11, 15)

Its a good idea to run as a select statement first before doing the update... select * from item where department id in (1, 2, 3, 4, 5, 8 9, 11, 15)

Don't forget to backup the db before running the update script....

What SQL giveth, SQL taketh away...

Cheers

"Phil V" wrote:

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required