set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgo-- =============================================-- Author: jiangbo-- Create date: 2014-07-09 13:32:20-- Description: 分页存储过程-- =============================================ALTER PROCEDURE [dbo].[GetPages]@PageIndex int,@PageSize int,@RecordCount int out,/*总记录数*/@PageCount int out/*总页数*/ASBEGIN /*获取数据的总记录数*/ select @RecordCount=count(*) from UserInfo /*计算总数据可以分成几个页面*/ set @PageCount = ceiling(@RecordCount*0.1/@PageSize)/*ceiling函数返回大于或等于所给数字表达式的最小整数。*/ select SerialNumber,Id,Name,Age,Sex,Email,Address,Phone from (select Id,Name,Age,Sex,Email,Address,Phone,ROW_NUMBER() over(order by Id desc) as SerialNumber from UserInfo) as T where T.SerialNumber >(@PageIndex*@PageSize) and T.SerialNumber <=((@PageIndex+1)* @PageSize)ENDselect * from UserInfo