加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

IN SQL Server数据库

发布时间:2020-12-12 16:13:21 所属栏目:MsSql教程 来源:网络整理
导读:在我的数据库中我有这个char .我想查询他们 Select * from Sometable where somecolumn like '%?%' 这让我没有结果. 我认为这是ANSI编码 解决方法 使用N如下 where col like N'%?%' why do you think,you need N prefix: Prefix Unicode character string co
在我的数据库中我有这个char .我想查询他们
Select * 
from Sometable 
where somecolumn like '%?%'

这让我没有结果.

我认为这是ANSI编码

解决方法

使用N如下
where col like N'%?%'

why do you think,you need N prefix:

Prefix Unicode character string constants with the letter N. Without the N prefix,the string is converted to the default code page of the database. This default code page may not recognize certain characters.

感谢马丁·史密斯,早些时候我只测试了一个字符,它的工作,但正如马丁指出,它返回所有字符..

以下查询工作和返回只有意图

select * from #demo where id  like N'%?%' 
COLLATE Latin1_General_100_BIN

演示:

create table #demo
(
id nvarchar(max)
)

insert into #demo
values
(N'?'),( N'?')

要了解更多关于unicode,请看下面的链接

http://kunststube.net/encoding/

https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读