sql-serversoundex

Sql Server Soundex Name search - find shortened form of a name


I would like to allow my app to search for names and return similar first names. I.e. if the user searches for John, Jonathan's should be returned as well.

A Soundex search does not seem to do this. Are there any alternatives other than storing a dictionary of related names?


Solution

  • You should look at Levenshtein Edit Distance, and look for strings with low edit distance comparing to target string.

    Here is more info and implementation of it for SQL Server

    http://www.kodyaz.com/articles/fuzzy-string-matching-using-levenshtein-distance-sql-server.aspx


    Edit distance shows minimum number of edits (character deletions, replacements or insertions) you need to make to a string to get your target string.

    So for example 'apple' and 'aple' will have an edit distance of 1 (deletion of 'p');

    3rd party edit

    The code from kodyaz.com points to a posting from Arnold Fribble on the sqlteam.com/forums You can find the code in this question from 2009