有一字段是人名(name):张三、李四、王二、王五、吴三....例如想查询以w开头的人名,结果是:王二、王五、吴三因为用的是虚拟空间,不支持函数,请问大家:可以用一个sql语句实现吗?谢谢先:)

解决方案 »

  1.   

    select * from 表 order by name COLLATE Chinese_PRC_CS_AS_KS_WS
      

  2.   

    --排序可以
    declare @t table([name] varchar(10))
    insert into @t select '张三'
    union all select '李四'
    union all select '王二'
    union all select '王五'
    union all select '吴三'select * from @t order by [name] collate Chinese_PRC_CI_AS
      

  3.   

    declare @t table(name varchar(10))
    insert into @t select '张三'
    insert into @t select '李四'
    insert into @t select '王二'
    insert into @t select '王五'
    insert into @t select '吴三'
    select 
        a.name 
    from 
        @t a,
        (select '吖' chr,'A' letter union all select '八','B' union all
         select '嚓','C' union all select '咑','D' union all
         select '妸','E' union all select '发','F' union all
         select '旮','G' union all select '铪','H' union all
         select '丌','J' union all select '咔','K' union all
         select '垃','L' union all select '嘸','M' union all
         select '拏','N' union all select '噢','O' union all
         select '妑','P' union all select '七','Q' union all
         select '呥','R' union all select '仨','S' union all
         select '他','T' union all select '屲','W' union all
         select '夕','X' union all select '丫','Y' union all
         select '帀','Z') b
    where
        b.chr<=left(a.name,1)
    group by 
        a.name 
    having max(letter)='W'/*
    name       
    ---------- 
    王二
    王五
    吴三
    */
      

  4.   

    谢谢老大libin_ftsafe(子陌红尘)!