分页存储过程

--SQL Server 中创建存储过程

create proc usp_UserConsultingPaging
@pageNumber int,--页码
@pageSize int,--条数
@sumCount int output --总页数
as begin
set @sumCount=(CEILING((select count(*) from [dbo].[DD_CustomerProblem])*1.0/@pageSize))
select * from (select 编号=ROW_NUMBER() over (order by [ProblemID]),* from [dbo].[DD_CustomerProblem]) as xb where xb.编号 between (@pageNumber-1)*@pageSize+1 and @pageNumber*@pageSize end

declare @sc int
exec usp_UserConsultingPaging 1,5,@sc output
select @sc

 

--SQL Server中执行存储过程

declare @sc int
exec usp_UserConsultingPaging 1,5,@sc output
select @sc --表示分几页

 

--SQL Server删除存储过程

 drop proc usp_UserConsultingPaging  

posted @ 2015-08-17 15:38  .追风逐月  阅读(150)  评论(0编辑  收藏  举报