i have 2 tables EmployeeData and employeePersonalData.
I have common column emailId.
Now I want copy all the emailId from employeeData to employeePersonalData
how can I do?
i have 2 tables EmployeeData and employeePersonalData.
I have common column emailId.
Now I want copy all the emailId from employeeData to employeePersonalData
how can I do?
you can visit similar question
It provides us two approach.
Before that please check you should be having one more common column similar to EmployeeId in both the tables.
so then you can use either of below approach -
1) using UPDATE FROM with a JOIN will help
Update employeePersonalData
set employeePersonalData.emailId =employeeData.emailId
from employeePersonalData inner join employeeData b
on employeePersonalData.emploeeId =employeeData.employeeId
2) Using merge
MERGE INTO employeePersonalData
USING employeeData
ON employeePersonalData.emailId =employeeData.emailId
WHEN MATCHED THEN
UPDATE
SET employeePersonalData.emailId =employeeData.emailId;
Update a set a.emailId =b.emailId from employeePersonalData a inner join employeeData b on a.emailId =b.emailId