我对西里尔字符“E”和“e”有疑问,当使用不区分大小写的排序规则时,它们应该相等。这对于除哈萨克语之外的所有归类都是正确的。
我使用以下查询检查了所有 CI 排序规则:
SELECT 'DECLARE @Test_' + name + ' TABLE (
Code nvarchar(32) COLLATE ' + name + '
)
INSERT @Test_' + name + ' (Code)
VALUES (N''Е''), (N''е'')
SELECT ''' + name + ''', * FROM @Test_' + name + ' WHERE Code = N''Е'' COLLATE ' + name
FROM sys.fn_helpcollations()
WHERE name LIKE '%CI%'
对于所有排序规则,但不是哈萨克语,都会按预期返回两行。
用于说明问题的示例查询:
SET NOCOUNT ON;
DECLARE @Test TABLE (
Code nvarchar(32) COLLATE Kazakh_90_CI_AS
);
DECLARE @UpperChar nchar(1) = N'Е';
DECLARE @LowerChar nchar(1) = N'е';
SELECT ASCII(@UpperChar) AS 'UpperChar ASCII', ASCII(@LowerChar) AS 'LowerChar ASCII';
/* Just ASCII-codes for the chars
UpperChar ASCII LowerChar ASCII
--------------- ---------------
197 229
*/
INSERT @Test (Code)
VALUES (@UpperChar), (@LowerChar);
SELECT DISTINCT Code AS 'DISTINCT Code' FROM @Test;
/* Should be one row with CI collation - FALSE
DISTINCT Code
--------------------------------
Е
е
*/
SELECT Code AS 'Code = @UpperChar'
FROM @Test
WHERE Code = @UpperChar;
/* Should be two rows with CI collation - FALSE
Code = @UpperChar
--------------------------------
Е
*/
SELECT Code AS 'Code = @LowerChar'
FROM @Test
WHERE Code = @LowerChar;
/* Should be two rows with CI collation - FALSE
Code = @LowerChar
--------------------------------
е
*/
SELECT Code AS 'Code = @UpperChar OR Code = LOWER(@UpperChar)'
FROM @Test
WHERE Code = @UpperChar
OR Code = LOWER(@UpperChar);
/*Check LOWER('Е') = 'е' - TRUE
Code = @UpperChar OR Code = LOWER(@UpperChar)
---------------------------------------------
Е
е
*/
SELECT Code AS 'Code = @LowerChar OR Code = UPPER(@LowerChar)'
FROM @Test
WHERE Code = @LowerChar
OR Code = UPPER(@LowerChar);
/*Check UPPER('е') = 'Е' - TRUE
Code = @LowerChar OR Code = UPPER(@LowerChar)
---------------------------------------------
Е
е
*/
其他 Сyrillic 字符的行为与预期一致。
我可以做什么来解决这个问题?