SQL2005分页查询语句! 简单实用
with temptbl as (SELECT ROW_NUMBER() OVER (order by ProductID)AS Row, * from Products)
SELECT * FROM temptbl where Row between (@pageindex)*@pagesize+1 and (@pageindex)*@pagesize+@pagesize
每次只读取17条数据出来,
简单测试了一下20多万条数据只用了93毫秒,如果全部查出来则要7秒。
实例如下:
with temptbl
as (SELECT ROW_NUMBER() OVER (order by ID)AS Row, * from tblstmTasklist)
SELECT * FROM temptbl
where Row between (0)*10+1 and (0)*10+10
SELECT * FROM tblstmTasklist