Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

How do I write a SQL query that will find misspellings of names or similar names?

I have a SQL database with two tables. One table called tblConflict has a field called conflict number, Plaintiff and Defendant.  The second table called tblConflict attorney has the link field conflict number and the name of the attorney.  I have all of it linked together with a view.  I want to be able to search for a name in the 3 columns ie Dorfman.  It might be in the database as Dorfman, Dorphman, Dorman, or Dorphmen depending how the user entered originally.  I need when you enter Dorfman that all four entries come up.
0
rphilipson
Asked:
rphilipson
  • 2
  • 2
1 Solution
 
NIMTUG_SimonCommented:
You have to use SQL Server Full text Searching and use the special search capibilities that once it is installed and configured it will return Dorfman and if you want the words that it thinks it is close to.
0
 
rphilipsonAuthor Commented:
I have tried Freetext and it doesn't do it.  Also, I have two tables that the view joins.  I don't think that any of the Fulltext Search capabilities span more than one table.  I might be mistaken but I can't find anything.  Perhaps if you have a SQL statement that will work you can enlighten me.

Thanks
0
 
NIMTUG_SimonCommented:
Try the SOUNDEX  DIFFERENCE funcations

http://support.microsoft.com/kb/100365
http://msdn.microsoft.com/en-us/library/ms187384.aspx
http://msdn.microsoft.com/en-us/library/ms188753.aspx

What you have to do is to find the SoundEx value of Dorfman and The other deriatives You can get a simularity value by using DIFFERENCE.

assuming @Search is the name you are searching on.

Select Name, SoundEx(Name) as SoundValue, DIFFERENCE(Name, @Search) as SoundDifference From Table

DIFFERENCE returns a value from 0 to 4 where 0 is the two strings are no way close to each other and 4 they are very close of the same.
0
 
rphilipsonAuthor Commented:
I had tried both soundex and difference and I still can't get it to do what I want it to do.  I am going to look at something like DTsearch that might work better.  I do appreciate your help.  I am going to mess around with it some more and see if I can get it or another solution to work.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now