数据库有十几万数据其中用户名中有2-3万的数据为中文,在sql中怎么才能查出包含中文的字段??
例如:name字段
       aaa
       张三
       bbb
       李四查询结果:张三
          李四
       

解决方案 »

  1.   

    select *
    from tb 
    where patindex('%[1-9]%',name)<0
      

  2.   

    select * from tb where name like '%[吖-做]%'
      

  3.   


    ---------------------------------
    --  Author: htl258(Tony)
    --  Date  : 2009-07-30 20:33:09
    ---------------------------------
    --> 生成测试数据表:tbIf not object_id('[tb]') is null
    Drop table [tb]
    Go
    Create table [tb]([name] nvarchar(3))
    Insert tb
    Select 'aaa' union all
    Select '张三' union all
    Select 'bbb' union all
    Select '李四'
    Go
    --Select * from tb-->SQL查询如下:
    select * from tb where name like '%[吖-做]%'
    /*
    name
    ----
    张三
    李四(2 行受影响)
    */
    select * from tb where patindex('%[吖-做]%',name)>0
    /*
    name
    ----
    张三
    李四(2 行受影响)
    */
      

  4.   

    -- =========================================
    -- -----------t_mac 小编-------------
       ---希望有天成为大虾---- 
    -- =========================================IF OBJECT_ID('tb') IS NOT NULL
      DROP TABLE tb
    GO
    CREATE TABLE tb(name varchar(20))
    go
    insert tb SELECT 
          'aaa' UNION ALL SELECT 
          '张三' UNION ALL SELECT 
          'bbb' UNION ALL SELECT 
          '李四'  
    go
    select *
    from tb 
    where name not like'%[a-z]%'
    go
    /*------------
    (4 行受影响)
    name
    --------------------
    张三
    李四
    -------*/
      

  5.   

    select *
    from tb 
    where   PATINDEX('%[a-z]%',name)=0
     
    /*name
    --------------------
    张三
    李四(2 行受影响)*/
      

  6.   


    select count(*) from bbb where name  like '%[吖-做]%'  ------结果为1.5w       ------------这个是name中只包含中文?如果有数字、英文都不行?select count(*) from bbb where name not like'%[a-z]%'  ------结果为2.2w
     
           ------------这个是name中只能有英文,不能有数字和中文?
      

  7.   

    ------------这个是name中只包含中文?如果有数字、英文都不行? 错,如果有中文和英文、数字,还是会统计出来的。If not object_id('[tb]') is null
        Drop table [tb]
    Go
    Create table [tb]([name] nvarchar(8))
    Insert tb
    Select 'aaa' union all
    Select '张三11' union all
    Select 'bbb' union all
    Select '李四aa'
    Go
    --Select * from tb-->SQL查询如下:
    select * from tb where name like '%[吖-做]%'
    /*
    name
    --------
    张三11
    李四aa(2 行受影响)
    */
      

  8.   

    经测试显示:
    select count(*) from bbb where name  like '%[吖-做]%'    这个只要包含中文都能查出select count(*) from bbb where name not like'%[a-z]%'    这个只要有英文的,哪怕中文加英文都查不出总结:第一个准谢谢大家
      

  9.   

    select count(*) from bbb where name not like'%[a-z]%'    这个只要有英文的,哪怕中文加英文都查不出 
    --这个可以查全英文或英文与其它字符的组合。
      

  10.   

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

  11.   

    not like'%[a-z]%'---------不是like了,张三aaaa,这样的就查不出来~~~~