码迷,mamicode.com
首页 > 其他好文 > 详细

分页存储过程

时间:2015-05-18 22:35:29      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

create proc usp_getPageData
    @totalCount int output,--总页数
    @pageIndex int ,--当前面索引
    @pageCount int--每一页显示的记录数
as
--获取拥有行号的结果集
--select ROW_NUMBER() over(order by sid) , * from dbo.vw_GetStockInfo
--从拥有行号的结果集中再进行查询,使用行号进行条件的判断:获取结果集
select * from  (select ROW_NUMBER() over(order by sid) id , * from dbo.vw_GetStockInfo) temp
where id between (@pageIndex-1)*@pageCount+1 and @pageIndex*@pageCount
--获取总页数
set @totalCount=CEILING((select count(*) from vw_GetStockInfo) *1.0/@pageCount)
go

 

分页存储过程

标签:

原文地址:http://www.cnblogs.com/DKnight/p/4513129.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!