sql-server - 选择包含正方形 2 的字符串
问题描述
我想选择包含正方形 2 的行(这个 char '²')
我确实select myColumn from table where myColumn '%²%'
得到了包含“²”的列,但也得到了包含“2”的列。
我试过select myColumn from table where myColumn '%2%'
了,我得到了同样的结果。
SQL Server 中有没有办法选择只包含正方形 2 字符的列?
解决方案
您必须使用正确的排序规则,Latin1_General_BIN
例如。
declare @t table(t nvarchar(20))
insert into @t values('²'), ('2')
-- Will return only the row with the number.
select * from @t where t like N'%2%' collate Latin1_General_BIN
-- Will return only the row with square 2.
select * from @t where t like N'%²%' collate Latin1_General_BIN
推荐阅读
- laravel - Laravel 7 Queue delete() 特定作业
- java - Build.gradle 中的运行时范围编译失败?
- layout - ExtJS 6.0.2 使用 hbox 布局创建具有两个嵌套面板的面板
- android - 如何使用 Kotlin 将字符串 Bold 放入 textView?
- android - 如何在点击 FCM 通知后不在后台重新打开应用程序
- oracle - 如何确定 BizTalk Oracle 适配器使用哪个 oracle 驱动程序
- java - SearchView工具栏界面Android Studio java中没有弹出项目
- python - 在 Python 中列出每个元素最多 2 次
- node.js - 通过对象数组循环项目,rooms.forEach 不是 ejs 中的函数
- reactjs - 在 ReactJS 中访问嵌套的 JSON 数据