SQL Server拉丁口音敏感排序规则

时间:2019-04-09 15:36:33

标签: sql sql-server full-text-search collation

我有以下查询

select T.[KEY] Id,  T.[RANK]  Score, D.Name,
CASE 
            WHEN D.Name = 'će' THEN 1000        
            WHEN D.Name  COLLATE Latin1_General_CI_AS LIKE 'će%' THEN 500       
            WHEN D.Name  LIKE 'će%' THEN 100        
            ELSE 10 
END MatchType
from containstable(Dishes, (Name), '("će*")', language 0x0, 15) as T
INNER JOIN Dishes D On T.[KEY] = D.DishId
ORDER BY MatchType Desc, Score Desc 

它会产生以下结果:

enter image description here

有人可以告诉我为什么“Ćevapi”在这种情况下没有500分的比赛分数吗?根据整理,应该吗?

在这种情况下,这里的重点是将će优先于ce

1 个答案:

答案 0 :(得分:2)

您正在将字符串文字转换为varchar。

坏:

select 1 
where N'Ćevapi' COLLATE Latin1_General_CI_AS LIKE 'će%'

好:

select 1 
where N'Ćevapi' COLLATE Latin1_General_CI_AS LIKE N'će%'