0

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

Fhd.ashraf
  • 113
  • 1
  • 2

1 Answers1

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