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. For example, both of the following strings have the same SOUNDEX codes:

SELECT SOUNDEX ('smith'), SOUNDEX ('smythe')
-----
-----
S530
S530


(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 to 4, where 4 is the best match. For example:

SELECT DIFFERENCE('smithers', 'smothers')


------------

4

(1 row(s) affected)




SELECT DIFFERENCE('smothers', 'brothers')


------------

2

(1 row(s) affected)