declare @test table(N char(10))insert @test 
select '张三' union all
select 'Apple' union all
select '李四' union all
select 'Banana' union all
select '赵六' union all
select 'Orange'如何判断字段里是否包含中文

解决方案 »

  1.   

    declare @test table(N char(10))insert @test 
    select '张三' union all
    select 'Apple' union all
    select '李四' union all
    select 'Banana' union all
    select '赵六' union all
    select 'Orange'if exists(select 1 from @test where PATINDEX('%[^吖-座]%',N)>0)
    print '有汉字'
      

  2.   

    上面错了declare @test table(N char(10))insert @test 
    select '张三' union all
    select 'Apple' union all
    select '李四' union all
    select 'Banana' union all
    select '赵六' union all
    select 'Orange'select n from @test where PATINDEX('%[吖-座]%',N)>0
      

  3.   


    厉害啊,能把中文全部选出来么,还有能解释下PATINDEX('%[^吖-座]%',N)是什么意思吗,多谢啦
      

  4.   


    LIKE N'%[一-龥]%' COLLATE Chinese_PRC_BIN
    --或是:
    LIKE N'%[吖-咗]%' COLLATE Chinese_PRC_CI_AS
    详见:SQLServer中文处理
      

  5.   


    %[吖-座]%的话,“座”字之后的7个字符是出不来的。declare @test table(N char(10))insert @test 
    select '张三' union all
    select 'Apple' union all
    select '李四' union all
    select 'Banana' union all
    select '赵六' union all
    select 'Orange' union all
    select '做'select n from @test where PATINDEX('%[吖-座]%',N)>0