Tuesday, February 24, 2015

SOUNDEX and DIFFERENCE Function in SQL Server.

The SOUNDEX function converts a character string to a four-digit code for use in a comparison. Vowels are ignored in the comparison. Non-alphabetic characters are used to end the comparison. This function always returns some value.

Syntax:
SOUNDEX ( character_expression )
The following example displays the results of the SOUNDEX function for the similar character strings of smith and smythe. When character strings are similar, both strings have the same SOUNDEX codes.

SELECT SOUNDEX ('Kumar'), SOUNDEX ('Kumara');
GO

Output:
----- -----
K560  K560

(1 row(s) affected)



DIFFERENCE ()

The DIFFERENCE function compares the SOUNDEX values of two strings and evaluates the similarity between themreturning a value from 0 through 4, where 4 is the best match. 

Syntax:
DIFFERENCE ( character_expression , character_expression )

See the following examples:

SELECT DIFFERENCE('Vimal', 'Vimal');
GO
SELECT DIFFERENCE('Vimal', 'Kamal');
GO
SELECT DIFFERENCE('Roy', 'John');
GO




Thanks!!

No comments:

Post a Comment