select idenetity(int,1,1) as iid, * into #temp from tablename
select top * from #temp where id<=10
go
select top * from #temp where id>10 and id<=20
go
参考:
http://expert.csdn.net/Expert/topic/2142/2142477.xml?temp=.7186701
分页处理
declare @SQLStr varchar(8000)
set @SQLStr='SELECT Top '+cast(@每页大小 as varchar)+' * FROM 表
WHERE num NOT IN (SELECT TOP '+cast(@每页大小*@第几页 as varchar)+' num from 表 )'
exec(@SQLStr)
查询N-M条记录。
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable order by 排序字段
select top M-N * from #temptable where iid>=N