I have two tables City with codes and other is the employees table.The issue while inserting was that instead of the Code of the city the actual name was inserted.I need to replace them with the codes.I have like 2400 employees.What kind of sql-query I should write to replace all the names of the city in the Employe table with the actual codes of the cities
Asked
Active
Viewed 61 times
1 Answers
0
A basic update statement will do the trick
UPDATE Employee
SET City = City.Code
FROM City
WHERE City.Name = Employee.City
This code makes some assumptions about your design, but you'll get the idea.

mrdenny
- 27,174
- 4
- 41
- 69