-- unicode(expression)函数返回​​字符​​串类型的unicode码

--中文对应的unicode码大致为(应该是精确的):19968-40869

declare @tb table

(

[a] varchar(50) 

)

insert @tb

select '客' union all

select '客' union all

select '中' union all

select 'a' union all

select '/' union all

select '.' union all

select '*' union all

select '@' union all

select '了' union all

select '鹰'

select [a] from @tb where unicode([a]) between 19968 and 40869

go

 

--结果

SQL数据库查询使用正则表达式查询中文_字段


补充回答:

如果在t-sql中想查看unicode码对应的​​字符​​可以用nchar(expression)函数

如:select nchar(19968)

结果:一

 

====================================================================



你的中文是指

字段中包含有中文

还是

字段全是有中文组成的


补充回答:

--> ​​测试数据​​:@tb

declare @tb table([name] varchar(10))

insert @tb

select '啊' union all

select '阿' union all

select '做' union all

select '111坐' union all

select '做qqq' union all

select '坐' union all

select '左' union all

select 'aaa' union all

select '。' union all

select '★' union all

select '123' union all

select '座'

--找到包含有汉字的列

select * from @tb where patindex('%[阿-做]%',name)>0

/*

name

----------

111坐

做qqq

(6 行受影响)

*/

--如果找到只有中文的列比较难,除非指定了长度,比如说一位就去点 %%

select * from @tb where patindex('[阿-做]',name)>0

 

unicode([a]) between 19968 and 40869 也可以实现相同的功能,但是效率不高