Monday, January 27, 2014

SQL Server Update table with value from a joined table.

This comes up rarely, but is a little esoteric so it is worth noting.  You want to update values in one table with a value from another table.  Use the following syntax:

UPDATE TableOne
SET ColumnOne = T2.ColumnFromT2
FROM TableOne T1
   Join TableTwo T2
      On T1.CommonId = T2.CommonId

No comments:

Post a Comment