UPDATE from SELECT query in SQL Server


This content was proof-read by Grammarly. You can Try Grammary for FREE

Assume a scenario where you have a temporary table contains the data and would like to update a table using the values from the temporary table.

Here’s an query demonstrating how to do it in SQL Server.

UPDATE
    Employee
SET
    Employee.Name = TempEmployee.Name,
    Employee.Address = TempEmployee.Address
FROM
    Employee 
    INNER JOIN TestEmployee AS TempEmployee
        ON Employee.id = TempEmployee.id
WHERE
    Employee.company = 'abundantcode'
%d bloggers like this: