This content was proof-read by Grammarly. You can Try Grammary for FREE
Below is a sample query that demonstrates how to update a table by getting the data from the select query in SQL Server. Assume that there are 2 tables AbundantCodeEmployee and AbundantCodeDepartment which contains the id . The id(in department) in this example refers to the department head . The columns “DepartmentName” is updated in the query based on the value retreived .
How to Update From Select Statement in SQL Server ?
UPDATE AbundantCodeEmployee SET AbundantCodeEmployee.DepartmentName = AbundantCodeDepartment.DepartmentName FROM AbundantCodeEmployee INNER JOIN AbundantCodeDepartment ON AbundantCodeEmployee.id = AbundantCodeDepartment.id