sq分页

 

create proc RowNumber @pageindex int,@pagesize int
AS
BEGIN

select * from 
(select ROW_NUMBER() OVER(order by CustomerID desc) as px,* from Customers) as a
where a.px between ((@pageindex - 1)* @pagesize + 1) and (@pageindex*@pagesize)

END

 

create proc Offset_Fetch @pageindex int,@pagesize int
AS
BEGIN

select * from Customers order by CustomerID desc
offset ((@pageindex - 1) * @pagesize) rows
fetch next @pagesize rows only  

END

 

参考:Sql Server多种分页性能的比较

 

posted on 2019-12-05 14:26  荆棘人  阅读(165)  评论(0)    收藏  举报

导航