Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

SQL - Update Duplicate Record

I have an anomaly in my database and I need to fix it.  Trying to figure out what caused it but in the meantime I need to fix the issue.  Have two tables.  Person and Employee.

Person has below fields (I'll only use the fields that are important).
Person.Id, Person.FN, Person.LN, Person.SN

Employee has the below fields (I'll only use the fields that are important)
Employee.EmpId, Person.Id, Employee.CID, Employee.FID

The issue is that there are two person records and two employee records.  
The two person records are John Doe and have two separate Employee records.  So lets say

123, John, Doe, 123456789
234, John, Doe, 123456789

567, 123, 888, 999
789, 234, NULL, NULL

The issue I have is the nulls. I have approximately 500 records that have this issue.  

How can I write an update statement to easily update record Employee.CID, Employee.FID of 789 with the Employee.CID, Employee.FID of 567 for the same person?

Update Employee
Set Employee.CID = (.....),
Employee.FID = (.....)

Avatar of ste5an
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How do you know which values should replace the NULL values?
Avatar of CipherIS


Thank You