Avatar of CipherIS
CipherIS
Flag 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

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

Employee
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 = (.....)

Thanks
Microsoft SQL Server 2008Microsoft SQL Server

Avatar of undefined
Last Comment
CipherIS

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

How do you know which values should replace the NULL values?
CipherIS

ASKER
Thank You
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck