The syntax for the SQL Server UPDATE statement when updating one table with data from another table is,
- UPDATE table1 SET table1.column = table2.expression1
- FROM table1 INNER JOIN table2
- ON (table1.column1 = table2.column1)
- [WHERE conditions];
For example,
- UPDATE student
- SET student.first_name = contacts.first_name
- FROM student
- INNER JOIN contacts ON (student.last_name = contacts.last_name)
- WHERE std_id > 20;