用存储过程实现。创建一个临时表,临时表的主键是一个自增长的字段id,其他列是你表的列,选择top 300插入临时表,然后取倒排序的100条,或者是row>200 and <=300条的记录就是你所要的记录
楼主是用存储过程来分面吧 :)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
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
---------
如果我想取1000000条记录后面的100条
那么就需要将10000100条数据填充到临时表
这样是不是会很消耗资源?
----------
你的注意不错
sql:
alter table tablename
add id int identity(1,1)select * from tablename where id>200 and id<=300