What is the MS SQL equivalent of this Access query?

I wrote this query in Access that pulls data from another table (County_Lookup) and populates rows in my main WORK table. Here is the Access SQL:

UPDATE [work] 
INNER JOIN county_lookup ON work.county_code = county_lookup.county_code
SET [work].division = county_lookup.division;

I am aware that in MS SQL I need to have the SET right after the UPDATE, but after that I don't really know. It gives me syntax errors specifically on the INNER JOIN command.

So this is as far as I have gotten.

UPDATE [work] 
SET [work].division = county_lookup.division
INNER JOIN county_lookup ON work.county_code = county_lookup.county_code;

1 answer

  • answered 2017-01-11 14:21 cloudsafe

    UPDATE w
    SET w.division = c.division
    from [work] w
    INNER JOIN county_lookup c ON w.county_code = c.county_code;