Open In App

SOUNDEX() Function in SQL Server

SOUNDEX() function :
This function in SQL Server is used to return a four character code in order to evaluate the similarity of two specified expressions.

Features :



Syntax :

SOUNDEX(expression)

Parameter :
This method accepts only one parameter as given below :



Returns :
It returns a four character code in order to evaluate the similarity of two given expressions.

Example-1 :
Getting a four character code of the specified expressions which sound similar.

SELECT SOUNDEX('see'), SOUNDEX('sea');

Output :

S000

Example-2 :
Using SOUNDEX() function with variables and getting a four character code.

DECLARE @exp1 VARCHAR(15); 
DECLARE @exp2 VARCHAR(15);
SET @exp1 = 'sum';
SET @exp2 = 'some';
SELECT SOUNDEX(@exp1), SOUNDEX(@exp2);

Output :

S500

Example-3 :
Getting a four character code of the specified expressions which doesn’t sound similar at all.

SELECT SOUNDEX('cs'), SOUNDEX('portal');

Output :

P634

Example-4 :
Getting a four character code of the specified expressions which are integer.

SELECT SOUNDEX(34), SOUNDEX(45);

Output :

0000

So, here no matter what the integer is the code generated will be “0000”.

Application :
This function is used to generate a four character code of the specified expressions.

Article Tags :
SQL