String Functions – DIFFERENCE()


I am going to continue my series of very short articles or tidbits on Transaction SQL string functions. I will exploring the DIFFERENCE() function today.

The DIFFERENCE() function takes two string arguments and computes how different the two strings sound when spoken. A return value of 4 means the strings sound the same while a value of 0 means the strings sound totally different.

When using the difference function, you should look at the SOUNDEX() function. This function calculates a four-character code that is based on how the string sounds when spoken.

The following two examples shows four different words representing animals. One pair is very simular and one pair is very different.

One thing to always worry about when using TSQL functions is how will it react with a UNKNOWN or NULL values?

Next time, I will be exploring the LEN() function.

Related posts

Leave a Comment