且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 s, t 与 SQL Server 中的 ş, ţ 进行比较

更新时间:2023-01-29 14:48:40

您指定的字符不是 Latin1 代码页的一部分,因此除了 中的序数外,它们不能以任何其他方式进行比较Latin1_General_CI_AI.事实上,我认为它们在给定的排序规则中根本不起作用.

The characters you've specified aren't part of the Latin1 codepage, so they can't ever be compared in any other way than ordinal in Latin1_General_CI_AI. In fact, I assume that they don't really work at all in the given collation.

如果您只使用一种排序规则,只需使用正确的排序规则(例如,如果您的数据是土耳其语,请使用 Turkish_CI_AI).如果您的数据来自多种不同的语言,则必须使用 unicode 和正确的排序规则.

If you're only using one collation, simply use the correct collation (for example, if your data is turkish, use Turkish_CI_AI). If your data is from many different languages, you have to use unicode, and the proper collation.

但是,还有一个问题.在罗马尼亚语或土耳其语等语言中,ş不是重音s,而是一个完全独立的字符 - 请参阅http://collat​​ion-charts.org/mssql/mssql.0418.1250.Romanian_CI_AI.html.与例如对比.šs 的重音形式.

However, there's an additional issue. In languages like Romanian or Turkish, ş is not an accented s, but rather a completely separate character - see http://collation-charts.org/mssql/mssql.0418.1250.Romanian_CI_AI.html. Contrast with eg. š which is an accented form of s.

如果你真的需要 ş 等于 s,你必须手动替换原始字符.

If you really need ş to equal s, you have replace the original character manually.

此外,当您使用 unicode 列(nvarchar 和一堆)时,请确保您还使用 unicode literals,即.使用 N'%iasi%' 而不是 '%iasi%'.

Also, when you're using unicode columns (nvarchar and the bunch), make sure you're also using unicode literals, ie. use N'%iasi%' rather than '%iasi%'.