日期:2014-05-18 浏览次数:20607 次
declare @pagesize int;set @pagesize=5 --定义每页的条数 declare @pageindex int;set @pageindex=2 --第几页 ;with maco as( --数据排序 select row_number() over (order by logData desc) as rid from tablename where logData between '2011-07-01' and '2011-07-30') select * from maco --分页 where rid between (@pageindex-1)*@pagesize+1 and @pageindex*@pagesize order by logData
------解决方案--------------------
declare @pagesize int;set @pagesize=5 --定义每页的条数 declare @pageindex int;set @pageindex=2 --第几页 ;with maco as( --数据排序 select row_number() over (order by logData desc) as rid,* --这里少写了一个星号,补上 from tablename where logData between '2011-07-01' and '2011-07-30') select * from maco --分页 where rid between (@pageindex-1)*@pagesize+1 and @pageindex*@pagesize order by logData