sql 判断字段是否包含中文

方法一 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
create   function   fun_getCN(@str   nvarchar(4000))   
  returns   nvarchar(4000)   
  as   
  begin   
  declare   @word   nchar(1),@CN   nvarchar(4000)   
  set   @CN=''   
  while   len(@str)>0   
  begin   
  set   @word=left(@str,1)   
  if unicode(@word)   between   19968   and   19968+20901 
      set   @CN=@CN+@word
  set   @str=right(@str,len(@str)-1)   
  end   
  return   @CN   
  end   
  
select dbo.fun_getCN('ASDKG论坛KDL')
论坛
select dbo.fun_getCN('ASDKG論壇KDL')
論壇
select dbo.fun_getCN('ASDKDL')
空字符串


方法二

1
select case when asciistr(a) like '%\%' then else end from table


方法三

1
SELECT FROM TB WHERE COL LIKE N'%[吖-咗]%'


方法四

1
select from [test].[dbo].[S456] where patindex('%[^0-9a-zA-Z ]%',[Importer])<>0


posted @   游子善心  阅读(16)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示