SOUNDEX SQL Server 2012 中的功能似乎已损坏
SOUNDEX function seems broken in SQL Server 2012
以下语句在 SQL Server 2012 中 return 不同的 SOUNDEX
值,而它们在 SQL 中产生 相同的值服务器 2008:
PRINT SOUNDEX('BAKHSHI') --B200
PRINT SOUNDEX('Bakhshi') --B220
有没有其他人在 SQL Server 2012 中遇到过这个问题并且知道如何解决它?
根据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)
因此您可能想尝试遵循 Microsoft 的升级路径建议。此外,SOUNDEX 对归类敏感 - 您的 2012 数据库归类是否与 2008 年的归类相同?
以下语句在 SQL Server 2012 中 return 不同的 SOUNDEX
值,而它们在 SQL 中产生 相同的值服务器 2008:
PRINT SOUNDEX('BAKHSHI') --B200
PRINT SOUNDEX('Bakhshi') --B220
有没有其他人在 SQL Server 2012 中遇到过这个问题并且知道如何解决它?
根据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)
因此您可能想尝试遵循 Microsoft 的升级路径建议。此外,SOUNDEX 对归类敏感 - 您的 2012 数据库归类是否与 2008 年的归类相同?