如何在 SQL Server 中执行不区分重音的比较(e 与 è、é、ê 和 ë)? [英] How do I perform an accent insensitive compare (e with è, é, ê and ë) in SQL Server?
问题描述
我想比较 SQL 中的两个 varchars,一个类似于 Cafe
,另一个 Café
在 SQL 中有一种方法可以允许这两个值进行比较.例如:
I'm looking to compare two varchars in SQL, one would be something like Cafe
and the other Café
is there a way in SQL that will allow the two values to be compared. For instance:
SELECT *
FROM Venue
WHERE Name Like '%cafe%'
所以如果有一个名为 Big Bobs Café Extraordinaire
的场所,它会被包含在结果集中吗?
So if there is a venue with the name Big Bobs Café Extraordinaire
it would be included in the result set?
推荐答案
强制不区分重音 整理
如果您想与表变量或临时表 varchar 列进行比较,您还需要确保双方具有相同的排序规则以避免错误或进一步的强制转换
You'll also need to ensure both side have the same collation to avoid errors or further coercions if you want to compare against a table variable or temp table varchar column
并且因为常量值将具有数据库更新的排序规则:仅用于局部变量,不适用于常量 不,即使如此
SELECT *
FROM Venue
WHERE
Name COLLATE Latin1_general_CI_AI Like '%cafe%' COLLATE Latin1_general_CI_AI
这篇关于如何在 SQL Server 中执行不区分重音的比较(e 与 è、é、ê 和 ë)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!