select *,identity(int,1,1) as aa
into #aa 
from table select id 
from #aa
where aa=300就可以了

解决方案 »

  1.   

    晕.忘了说了。。
    ID是不连续的  ID值是未知的。
    只知道在第几行
      

  2.   

    考虑到你说的情况 了,identity(int,1,1)  等于 新加了一个由1 开始 自增的列,但是 必须要有 into 子句,上面的就可以了,选第几行 条件等于 几就可以了
      

  3.   

    问题是  1000万记录时,你这样 只是identity(int,1,1) 到临时表也够慢吧
      

  4.   


    select * from tb a where (select count(*) from tb where id<=a.id)=300
    这种情况需要id唯一.id有顺序排列,比如id为1,5,6..1,6,5这种就不成
      

  5.   


    select top 1 id from( 
    select top 300 * from tb
    order by id ) aa
    order by id desc
      

  6.   

    用SET ROWCOUNT 这个数据量大时效率比较高的
      

  7.   

    SET ROWCOUNT 300select top 1 * from table1 order by [id] descSET ROWCOUNT 0
      

  8.   

    上面的错了,不用descdeclare @i intset Rowcount 300select @i = autoid From kjMain order by autoidset Rowcount 0Print @i