微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

IN SQL Server数据库

在我的数据库我有这个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/

原文地址:https://www.jb51.cc/mssql/82716.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐