How to use a select in update statement using MSSQL

To use a select statement in a update statement using MSSQL you can use the snippet below.

Sample SQL

UPDATE TableOne
SET
    t1.ColumnOne = t2.ColumnOne,
    t1.ColumnTwo = t2.ColumnTwo
FROM
    TableOne AS t1
INNER JOIN
    TableTwo AS t2
ON
    TableOne.id = TableTwo.id

Please Share us:
Please rate this snippet

4 thoughts on “How to use a select in update statement using MSSQL

Leave a Reply