Update rows from another table

40,083
UPDATE  q
SET     country = a.country
FROM    quantity q
JOIN    acronym a
ON      a.acronym = q.country
Share:
40,083
Avinash
Author by

Avinash

I'm just a reports guy..

Updated on July 05, 2022

Comments

  • Avinash
    Avinash about 2 years

    I have a table with 2 columns, Country and Qty. the field country has distinct acronyms of all the countries. Now my job is to replace those acronyms with the actual country name. Now there is another table with acronyms and corresponding country names. I have to take the values from this second table and update the first one where Acronyms match. Please help..

  • Chris Moutray
    Chris Moutray over 12 years
    +1 I've used tsql for years and never realised an alias could be used next to the update keyword!
  • Thomas Fonseca
    Thomas Fonseca over 10 years
    Thanks Quassnoi! I found your answer helpful - now I can go home!