This article aims to help you understand the DIFFERENCE()
function, which is a T-SQL function available in SQL Server, Azure, etc.
The key to understanding the DIFFERENCE()
function is to understand how Soundex works (or in the context of SQL Server, how the SOUNDEX()
function works). This is because the DIFFERENCE()
function returns the difference between the Soundex values between two strings.
A Soundex value is four characters long. If two words sound the same, they will share the same four character Soundex value. If they sound similar (but not the same), their Soundex values might share some characters but not all. For example, their Soundex values might have two characters the same and two that are different. If two words sound completely different, none of the characters in their respective Soundex values will be the same.
The DIFFERENCE()
function returns a value that ranges from 0
through 4
. This value represents the number of characters in the Soundex values that are the same. 0
indicates weak or no similarity, and 4
indicates strong similarity or the same values.
Continue reading →