Thursday, October 21, 2010

SQL Server - Update columns of a table by taking values from another table

Update columns of Table 1 with corresponding values from Table 2 based on the values of a third common column.


UPDATE Table_Name1
SET
col1 = Table_Name2.col1,
col2 = Table_Name2.col2,
FROM Table_Name1, Table_Name2
WHERE Table_Name1.col3 = Table_Name2.col3

GO

No comments:

Post a Comment