select NO=(select sum(1) from sysobjects where id<=a.id)-1
from sysobjects a
where (select sum(1) from sysobjects where id<=a.id)<52
order by NO

解决方案 »

  1.   

    select top 51 NO=a.NO*16+b.NO*4+c.NO
    from(
    select NO=0 union all select 1 
    union all select 2 union all select 3
    )a,(
    select NO=0 union all select 1 
    union all select 2 union all select 3
    )b,(
    select NO=0 union all select 1 
    union all select 2 union all select 3
    )c
    order by NO
      

  2.   

    老大的好,我試了半天,還是處理不了一個0
    select  top 50 count(*) as id1   
    from (select id  from sysobjects )  as p1, (select id+1 as id from sysobjects )  as p2 
    where p1.id>p2.id
    group by p1.id 
    order by p1.id
      

  3.   

    to: zjcxc(: 邹建 :) 
    还是你的语句简单!
    请问下面的语句为什么能区分大小写?(不是说SQL默认是不区分大小写吗?)declare @c31 char(9)
    set @c31='ABCDFba' if exists(
    select count(*) 
    from(
    select id=a.id+1
    from(
    select id=0 union all select 1
    union all select id=2 union all select 3
    union all select id=4 union all select 5
    union all select id=6 union all select 7
    union all select id=8 union all select 9
    ) a
    )a where id<=len(@c31)
    group by substring(@c31,id,1)
    having count(*)>1
    ) select 0 else select 1
      

  4.   

    SQL默认是不区分大小写
    http://expert.csdn.net/Expert/topic/2885/2885583.xml?temp=.8550836