笔记23 row_number over()分页存储过程
笔记23 row_number over()分页存储过程
1 --row_number over()分页存储过程 2 DECLARE @pageSize INT 3 DECLARE @pageindex INT 4 SELECT @pageSize=5 ,@pageindex=2 5 ; 6 with 7 id as( 8 select 9 row_id = row_number() over(order by RecordNo asc), 10 RecordNo -- 主键列名 11 from dbo.SystemPara 12 ) 13 select 14 data.* 15 from dbo.SystemPara data 16 inner join id 17 on id.row_id = data.RecordNo 18 where id.row_id >(@pageSize*(@pageindex-1)) 19 and id.row_id < (@pageSize*(@pageindex))