我想查询数据库中的记录,由于很多我想每次查询一些,一般查询出来100条左右。当然如果查询前一百条可以这样 select top 100 * from table 如果查询再一百条怎么办?

解决方案 »

  1.   

    --SQL server 2005,2000中借用临时表
    declare @页数 int
    declare @页大小 int
    set @页数=1 --第一页,修改参数即可
    set @页大小=100
    select * from
    (
    select *,Row_number() over(order by 字段) as rownumber from 表
    ) T
    where rownumber between (@页数-1)*@页大小+1 and @页数*@页大小
      

  2.   

    select top 200 * from table where not exists(select top 100 * from table)
      

  3.   

    有主键 (id) 吗?有可以这样: 
    select top 100 * from table where id not in (select  top 100 id from table order by id)
      

  4.   

    sele * from 表 where recno() between 100 and 200
      

  5.   

    select top 100 * from table where id not in (select  top 100 id from table order by id)
      

  6.   

    --有ID得话 select top 100 * from (select top 200 * from 表 order by id DESC) T