I have 2 tables
Table Customers:
id,
CustomerName
Table CustomerMapping
ID
WrongName,
CorrectedName
What I want to do is :
Update my TableCustomers.CustomerName with the TableCustomerMapping.CorrectName if TableCustomers.CustomerName = TableCustomerMapping.WrongName
I tried this update statement but it is taking way too long, (6+ minutes) before I give up and cancel the query. I should not be taking that long to update 1000 rows.
Here is the Update statement I was trying, am I missing something?
UPDATE i
SET i.CustomerJob = c.CorrectedName
FROM dbo.TableCustomers i
LEFT JOIN dbo.CustomerMapping c ON (i.CustomerJob = c.WrongName);
GO
If those two tables related by
c.CustomerName = m.WrongName.Also note,
there could be more than one person with same wrong name & correct name. Given the situation (not related by IDs) I think following (INNER JOIN or JOIN) will do the job;