存储过程分页
alter proc proc_Customers_pageindex
(
@pageindex int,
@pagesize int,
@count int output
)
as
select @count=count(*) from Customers
select * from (
select row_number() over(order by CustomerID) as 'rowindex',* from Customers) as Customers_pageindex
where rowindex>@pageindex*@pagesize and rowindex<=(@pageindex+1)*@pagesize
return @count
select * from Customers
declare @count int
exec proc_Customers_pageindex 0,5,@count output select @count '总数'
select * from (
select row_number() over(order by CustomerID) as 'rowindex',* from Customers) as Customers_pageindex
where rowindex>=0+1 and rowindex<10+1
立志欲坚不欲锐,成功在久不在速。