蝸牛漫步

存储过程分页

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 

posted on 2011-02-19 22:56  蝸牛漫步  阅读(181)  评论(0编辑  收藏  举报

导航