question

fashraf avatar image
fashraf asked

Match Same column and replace the values.

Hi. 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 .
tablesmssqlreplace
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
fashraf avatar image
fashraf answered
UPDATE e SET City = c.Code FROM Employe AS e INNER JOIN City AS c ON c.City = e.City *Just had to tnk a little harder :)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.