sq分页 Sql Server多种分页性能的比较

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多种分页性能的比较

猜你喜欢

转载自www.cnblogs.com/Tpf386/p/11989098.html