Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
one table I have a person named HARVEY G BRACKETT, this would be first name, middle name, and last name field.

in another table the same person under full name is Harvey Gilbert Bracket. both tables show the exact same data for birth date and death date as well as place of death. So, I know that this is the correct person.

how can I compare with certainty what I would like is do something that compares the full name by the all the parts of table one first name, middle name, last name.

CHARINDEX(a.[First name], b.Name, 1) >0 and CHARINDEX(a.[Middle name], b.Name, len(a.[First name]) + 1) >0 and CHARINDEX(a.[Last name], b.Name, len(a.[Middle name]) + len(a.[First name]) + 2) >0


I want to go through each part of the string without starting back at position 1.

table 1 First name Harvey has 6 letters

if
CHARINDEX(a.[First name], b.Name, 1) >0
is true then start at position 7

table 1 middle name G

if
len(a.[First name]) + 1 >0
is true then start at new position to match last name inside the full name.

full code is listed below in what have you tried section?

What I have tried:

what I have so far, but I am not sure that its correct:

select * FROM table1 AS b
  INNER JOIN table2 AS a
ON CHARINDEX(a.[First name], b.Name, 1) >0 and CHARINDEX(a.[Middle name], b.Name, len(a.[First name]) + 1) >0 and CHARINDEX(a.[Last name], b.Name, len(a.[Middle name]) + len(a.[First name]) + 2) >0

where a.birth_date = b.birth_date and a.death_date = b.death_date
Posted
Updated 3-Dec-21 0:26am

1 solution

This is a very complex thing to attempt to do in SQL - I know, I've tried!

You may want to try the SOUNDEX function[^]

I eventually used a method that combined sql soundex with coded processing in my business layer... I store names as title, first forename, middle names, surname, initials (separated by spaces), suffixes. The incoming data can be in all sorts of formats - including preferred names. So I also have a table of mapping preferred names to full names e.g. "Ed" to "Edward".

To aid performance I first get a smaller temp table of surnames with matching soundex then essentially do rounds of iterative "confidence in match". At one point I was also calculating the Levenshtein distance (Optimizing the Levenshtein Distance for Measuring Text Similarity - KDnuggets[^]) but the whole process ran as fast as a dog with no legs, so we dropped that. I get about an 85% match and the rest drop out for manual matching.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900