Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize
14 out of 23 rated this helpful - Rate this topic

SOUNDEX

SQL Server 2000

Returns a four-character (SOUNDEX) code to evaluate the similarity of two strings.

Syntax

SOUNDEX ( character_expression )

Arguments

character_expression

Is an alphanumeric expression of character data. character_expression can be a constant, variable, or column.

Return Types

char

Remarks

SOUNDEX converts an alpha string to a four-character code to find similar-sounding words or names. The first character of the code is the first character of character_expression and the second through fourth characters of the code are numbers. Vowels in character_expression are ignored unless they are the first letter of the string. String functions can be nested.

Examples

This example shows the SOUNDEX function and the related DIFFERENCE function. In the first example, the standard SOUNDEX values are returned for all consonants. Returning the SOUNDEX for Smith and Smythe returns the same SOUNDEX result because all vowels, the letter y, doubled letters, and the letter h, are not included.

-- Using SOUNDEX
SELECT SOUNDEX ('Smith'), SOUNDEX ('Smythe')

Here is the result set:

----- ----- 
S530  S530  

(1 row(s) affected)

The DIFFERENCE function compares the difference of the SOUNDEX pattern results. The first example shows two strings that differ only in vowels. The difference returned is 4 (lowest possible difference).

-- Using DIFFERENCE
SELECT DIFFERENCE('Smithers', 'Smythers')
GO

Here is the result set:

----------- 
4           

(1 row(s) affected)

In this example, the strings differ in consonants, so the difference returned is 2 (higher difference).

SELECT DIFFERENCE('Anothers', 'Brothers')
GO

Here is the result set:

----------- 
2           

(1 row(s) affected)

See Also

String Functions

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.