首页 > Web开发 > 详细

.NET中实现分页的存储过程

时间:2016-01-14 20:39:33      阅读:201      评论:0      收藏:0      [点我收藏+]

alter proc getdatabypageindex
@PageIndex int=1, --页码
@PageSize int=6, --分页规格
@PageCount int output --页码总数
as
declare @StartIndex int,@EndIndex int
set @StartIndex=(@PageIndex-1)*@PageSize+1
set @EndIndex=@PageIndex*@PageSize

select * from
(
select ROW_NUMBER() over(order by id asc) as RowNum,*from dbo.Administrator_ManageFunction
) as tempTable
where RowNum between @StartIndex and @EndIndex
declare @PageCount1 int
set @PageCount1=(select COUNT(*) from dbo.Administrator_ManageFunction)%@PageSize
declare @PageCount2 int
set @PageCount2=(select COUNT(*) from dbo.Administrator_ManageFunction)/@PageSize
if(@PageCount1=0)
begin
set @PageCount=@PageCount2
end
else
begin
set @PageCount=@PageCount2+1
end
go

declare @PageCount int
exec getdatabypageindex 1,13,@PageCount output
select @PageCount

.NET中实现分页的存储过程

原文:http://www.cnblogs.com/menliu/p/5131476.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!