Tuesday, October 26, 2010

Difference between Soundex and Difference() function in Sql Server

SoundEX will return 4 letters code, this is used to compare two strings. for example
SELECT SOUNDEX ('cat'), SOUNDEX ('dog')
will return
C300 D200

DIFFERENCE finction will return 0 to 4, 4 indicates the best match.
SELECT DIFFERENCE('principal', 'principle') is 4, because those strings are almost similar, But a query looking at the difference between the words cat and dog shows a different result:
SELECT DIFFERENCE('cat', 'dog')is 2, not a best match

No comments:

Post a Comment