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

 

 

转载来自:http://www.cnblogs.com/xiayang/archive/2011/04/13/2014634.html

posted @ 2016-03-21 16:02  MORROW  阅读(108)  评论(0编辑  收藏  举报