Mid
DML
SQL & Databases
How do you update a table using JOIN in SQL Server?
Short answer: T-SQL supports UPDATE ... FROM with JOINs. Be careful with one-to-many joins (nondeterministic updates). Prefer MERGE or ensure uniqueness.
Sample solution
T-SQL
UPDATE e SET e.DepartmentName = d.Name FROM Employees e INNER JOIN Departments d ON d.DepartmentId = e.DepartmentId;
Mention nondeterministic update risk if multiple matched rows exist.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png