[英]SQL WHERE clause for column all capitalized
table_beatles
contains the following data in column name
. table_beatles
的列name
包含以下数据。
In MS-SQL is there anyway to get any item which is all caps? 在MS-SQL中,是否有任何项目可以大写? eg 例如
SELECT * FROM table_beatles where name is (AllCaps SYNTAX HERE)
to return PAUL and RINGO. 返回保罗和林戈。
How you do this depends on the collation used. 如何执行此操作取决于所使用的排序规则。 If you have a case insensitive collation, you are asking SQL to treat lower and upper case the same. 如果您有不区分大小写的排序规则,则要求SQL将大小写相同。 So you may need to do this: 因此,您可能需要这样做:
SELECT *
FROM table_beatles
WHERE UPPER(name) COLLATE Latin1_General_CS_AS
= name COLLATE Latin1_General_CS_AS
This forces SQL to use a case sensitive (CS) comparison for the equality check. 这将强制SQL使用区分大小写(CS)的比较进行相等性检查。 If you already have a case sensitive collation, then you can omit the two COLLATE
parts of this. 如果您已经具有区分大小写的排序规则,则可以省略其中的两个COLLATE
部分。 But given you've asked the question, I'm guessing you haven't. 但是考虑到您提出的问题,我想您还没有。
You want to do a case sensitive search. 您要进行区分大小写的搜索。 There are many methods explained here: Case sensitive search in SQL Server queries 此处介绍了许多方法: SQL Server查询中的区分大小写搜索
SELECT * FROM table_beatles where UPPER(name) = name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.