Glen Goodrick
Glen Goodrick

Reputation: 13

SOUNDEX function seems broken in SQL Server 2012

The following statements return different SOUNDEX values in SQL Server 2012 while they produce the same value in SQL Server 2008:

PRINT SOUNDEX('BAKHSHI') --B200

PRINT SOUNDEX('Bakhshi') --B220

Has anyone else had this issue in SQL Server 2012 and knows how to get around it?

Upvotes: 1

Views: 432

Answers (1)

Shan Plourde
Shan Plourde

Reputation: 8726

According to https://msdn.microsoft.com/en-us/library/bb510680.aspx:

SOUNDEX function implements the following rules: If upper-case H or upper-case W separate two consonants that have the same number in the SOUNDEX code, the consonant to the right is ignored If a set of side-by-side consonants have same number in the SOUNDEX code, all of them are excluded except the first. The additional rules may cause the values computed by the SOUNDEX function to be different than the values computed under earlier compatibility levels. After upgrading to compatibility level 110, you may need to rebuild the indexes, heaps, or CHECK constraints that use the SOUNDEX function. For more information, see SOUNDEX (Transact-SQL)

So you might want to try following Microsoft's upgrade path advice. Also, SOUNDEX is collation sensitive - are your 2012 DB collations the same as your 2008 collations?

Upvotes: 1

Related Questions