The soundex function converts a string to a four-digit number.CodeTo be used in comparison. The vowels are ignored during comparison. Non-letter characters are used to end the comparison. This function always returns a value.
The following example showsSoundex
Functions for similar stringsSmith
AndSmythe
. When two strings are similar, their soundex code is the same.
Select soundex ('Smith '), soundex ('smy'); go
The following is the result set:
----- S530 s530 (1 row (s) affected)
The difference function compares the soundex values of two strings and evaluates their similarity,Returns a value between 0 and 4.4 indicates the highest matching. The first one in the following exampleSelect
ReturnedDifference
Is4
Because Smithers and smothers have only one character.
Select difference ('smithers', 'smothers '); go
The following is the result set:
------------ 4 (1 row (s) affected)
The following example returnsDifference
Is3
. This indicates that although two strings have several different characters, they have similar pronunciations.
Select difference ('jeff ', 'geoffe'); go
The following is the result set:
----------- 3 (1 row (s) affected)