码迷,mamicode.com
首页 > 数据库 > 详细

SQL 数据库分页语句

时间:2015-11-27 12:50:49      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

declare @pagesize integer,@cpage integer;
set @pagesize =500;
set @cpage = 1;

SELECT TOP (@pagesize) * FROM 
     (SELECT row_number() over(order by MemberID) as row_number,* FROM (SELECT * FROM Member WHERE 1=1 ) Temp ) TEMPTABLE  
WHERE 1=1 AND row_number 
NOT IN(
SELECT TOP ((@cpage - 1) * @pagesize) row_number FROM 
      (SELECT row_number() over(order by MemberID) as row_number,* FROM (SELECT * FROM Member WHERE 1=1 ) Temp ) TEMPTABLE  
    WHERE 1=1 ORDER BY row_number ASC 
) ORDER BY row_number ASC;

 

SQL 数据库分页语句

标签:

原文地址:http://www.cnblogs.com/rinack/p/5000185.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!