The following forum(s) have migrated to Microsoft Q&A: All English SQL Server forums! Visit Microsoft Q&A to post new questions.
Updating a column in 1 table with value from another column in another table
Why the following code doesn't work?
UPDATE TableX INNER JOIN TableY ON TableX.UserID = TableY.UserID SET TableX.DepartmentID = [tabley].[departmentID];
Try :
UPDATE TableX SET TableX.DepartmentID = Y.[departmentID] From TableX X INNER JOIN TableY Y ON X.UserID = Y.UserID
UPDATE X
SET X.DepartmentID = Y.DepartmentID
FROM
TableX X
INNER JOIN
TableY Y
ON
X.UserID = Y.UserID