Sql server update multiple columns from another table

后端 未结 4 1193
余生分开走
余生分开走 2021-02-19 17:35

I have read lots of post about how to update multiple columns but still can\'t find right answer.

I have one table and I would like update this table from another table.

4条回答
  •  攒了一身酷
    2021-02-19 18:28

    TSQL does not support row-value constructor. Use this instead:

    UPDATE table1 
    SET a = t2.a,
        b = t2.b,
        (...)
    FROM 
    (
    SELECT ..... with join ... WHERE .... 
    ) t2
    WHERE table1.id = table2.id
    

提交回复
热议问题