s

mssql update from select inner join edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 23 September 2020 | 2560

MSSQL query to update a table by joining from another table. In this below sample there are two tables TableA and TableB and you want to update TableA by joining two tables.

SQL Query

UPDATE
    TableA
SET
    TableA.col1 = TableB.col1,
    TableA.col2 = TableB.col2
FROM
    TableA
    INNER JOIN TableB
        ON TableA.id = TableB.id
WHERE
    TableA.col3 = 'something'