我想取出第200条记录后面的100条数据
SQL语句怎么写?
【注意】主键可能不连续
-----
可以定义
page=200;
pagenum=100;

解决方案 »

  1.   

    用存储过程实现。创建一个临时表,临时表的主键是一个自增长的字段id,其他列是你表的列,选择top 300插入临时表,然后取倒排序的100条,或者是row>200 and <=300条的记录就是你所要的记录
      

  2.   

    楼主是用存储过程来分面吧 :)create procedure Paging
    as
    declare @maxId int
    -- 取得200条记录中最大的ID号
    select top 200 @maxId = max(id) from tableName order by id asc-- 然后查找大于200条记录中最大ID号后面的100数据
    select top 100 * from tableName where id > @maxId order by id asc
      

  3.   

    TO:dattotzy(酋长) 
    ---------
    如果我想取1000000条记录后面的100条
    那么就需要将10000100条数据填充到临时表
    这样是不是会很消耗资源?
      

  4.   

    To:exboy(kuku) 
    ----------
    你的注意不错
      

  5.   

    我的办法是在表中增加一个标志列,然后取标志列数据>200 and <=300
    sql:
    alter table tablename
    add id int identity(1,1)select * from tablename where id>200 and id<=300