如何在SQL中识别unicode文本? [英] How to identify unicode text in SQL?

查看:623
本文介绍了如何在SQL中识别unicode文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Table1有一个名为umsg的nvarchar列,其中包含unicode文本,还有一些时间也是英文。



我想查找umsg列中的英文文本。



Table1 has nvarchar column called umsg which contains unicode text and some time english also.

I want to find out English text present in umsg column.

select * 
from table1 
where 
    RDate >='01/01/2014' and RDate < '09/26/2017' 
    and umsg = convert(varchar(max), umsg)





我用上面的查询在区域语言中工作正常,但有些时候会失败。假设col包含'refnoété'这样的文本我认为上面的消息是unicode,如果我使用上面的查询,它/ sql显示我是英文而不是unicode。如何处理这个。



我的尝试:





I used above query that work fine in regional language but some time fail. Suppose col contain text like 'ref no été' I think above message is unicode, if I used above query, it/sql is showing me as English not unicode.How to handle this.

What I have tried:

select * 
from table1 
where 
    RDate >='01/01/2014' and RDate < '09/26/2017' 
    and umsg = convert(varchar(max), umsg)

推荐答案

试试这个吧工作....

Try this it's working ....
create table #test (
   uni nvarchar(100) 
)

insert into #test (uni) values (N'法的書面'),( 'asdf'), (N'Foo'), ('Bar')

select *
from #test
where uni <> convert(varchar(max), uni)


这篇关于如何在SQL中识别unicode文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆