TSQL 比较字符串/Varchars 同时忽略大小写/大写?
我正在处理一个查询,以便可以将从文件名中读取的单词与代码中已预定义的另一个单词进行比较,并为其分配一个数值。
然而,我遇到的问题是试图忽略名称的大小写,因为名称是从文件中读取的,大小写可能会发生变化,然后与我设置的预定义值不匹配。除了将所有可能的值放入案例中之外,是否有任何简单的方法可以忽略大小写?
代码片段:
NumberVal = CASE
WHEN Name = 'Bond' OR Name = 'BOND' OR Name = 'bond' THEN 16
END
I am working on a query so that I can compare a word read from a file name to another word that is already predefined in the code and assign it a numeric value.
However, the issue I am running into is trying to ignore the case of the name, because the name is being read from a file the case could change and then would not match the predefined value I have set. Is there any easy way to ignore the capitalization other than putting every possible value in the case?
code snipit:
NumberVal = CASE
WHEN Name = 'Bond' OR Name = 'BOND' OR Name = 'bond' THEN 16
END
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQL Server 默认忽略大小写,因此有人更改了您不知道的设置
如果现在区分大小写,则只需使用 UPPER 并忘记排序规则
SQL Server be default ignores case so someone has changed the setting ot youdidn't know
If it is now case sensitive, just use UPPER and forget collation