码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2016-01-14 20:42:41      阅读:197      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!