Technical Article

Find Duplicate Employees, Customers, Etc.

,

Customers, employees, etc. come and go.  They get entered multiple times in inconsistent formats in databases.

This simple script finds the duplicates across multiple formats and is easily modified as needed.  It's so easy, my grandmother could do it. Oops! No offense Grandma.

For very large databases, create and join two temp tables indexed on the namedatetring value.

/*
sqryIdentifyDuplicateEmployees

Created by Larry Ansley 5/30/03.

Matches John Q.Smith, Jr. born 6/15/50
with John Q Smith Jr born 6-15-1950.

Does not match Tom Smith born 8/1/40
with Tom Smith born 5/3/45.

Eliminates spaces, periods, and commas for
comparison purposes.

*/
Select EmpID, EmpName, BirthDate,
Addr1, Addr2, City, State, Zip
From Employees
Where Replace(Replace(Replace
(EmpName + Convert(Char(8),BirthDate,1),
' ',''), '.',''), ',','')
In

(Select Replace(Replace(Replace
(EmpName + Convert(Char(8),BirthDate,1),
' ',''), '.',''), ',','')
From Employee
Group By Replace(Replace(Replace
(EmpName + Convert(Char(8),BirthDate,1),
' ',''), '.',''), ',','')
Having Count(*) > 1)

Order By Replace(Replace(Replace
(EmpName + Convert(Char(8),BirthDate,1),
' ',''), '.',''), ',','')

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating