Thursday, April 7, 2016

UPDATE from SELECT using SQL Server

Below syntax will show you how the table A data is updated with table B values from select query
UPDATE Table_NA
SET
    Table_NA.col1 = Table_NB.col1,
    Table_NA.col2 = Table_NB.col2
----select query started
FROM
    Some_Table Table_NA
INNER JOIN
    Other_Table Table_NB
ON
    Table_NA.id = Table_NB.id
WHERE
    Table_NA.col3 = 'NEW'