Solved

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

Posted on 2008-06-11
4
255 Views
Last Modified: 2010-04-21
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
Comment
Question by:rphilipson
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21765006
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
 

Author Comment

by:rphilipson
ID: 21765294
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
 
LVL 3

Accepted Solution

by:
NIMTUG_Simon earned 125 total points
ID: 21766484
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
 

Author Closing Comment

by:rphilipson
ID: 31466395
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question