Feel free to ask tough questions relating to Crystal Reports / SQL Reporting Services / SQL and get answers from Collective intelligence
Wednesday February 8th 2012

Comparing SOUNDEX and DIFFERENCE

The SOUNDEX function converts a character string to a four-digit code for use in a comparison. Vowels are ignored in the comparison. Nonalphabetic characters are used to terminate the comparison. This function always returns some value.
This example displays the results of the SOUNDEX function for the similar character strings of “chappel” and “chapelle”. When character strings are similar, both strings have the same SOUNDEX codes.
select SOUNDEX (‘chappel’), SOUNDEX (‘chapelle’)
Here is the result set:
—– —–
C140 c140
(1 row(s) affected)
The DIFFERENCE function compares the SOUNDEX values of two strings and evaluates the similarity between them, returning a value from 0 through 4, where 4 is the best match. This example returns a DIFFERENCE of 4 for the first SELECT because “chappel” and “chappelle” differ by only 2 characters i.e extra l and extra e and the 4 no of characters are similar.
select difference (‘chappel’, ‘chapelle’) Here is the result set:
————
4
(1 row(s) affected)

Leave a Reply