码迷,mamicode.com
首页 > 数据库 > 详细

sql server分页存储过程

时间:2016-09-06 15:27:42      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

create proc [dbo].[messageMgr]
    @pageSize int,
    @pageIndex int,
    @rcount bigint output--输出查询总记录数
as
begin
declare @startRowNum int;
declare @endRowNum int;
set @startRowNum=@pageSize*(@pageIndex - 1)+1;
set @endRowNum=@pageIndex*@pageSize;

    select * from (
    SELECT ROW_NUMBER() over(order by a.short_message_time  desc) as number,*
    FROM short_message_info as a) as a
    where a.number between @startRowNum and @endRowNum;

    select @rcount=count(number) from (
    SELECT ROW_NUMBER() over(order by a.short_message_time  desc) as number,*
    FROM short_message_info as a) as a
end

 

sql server分页存储过程

标签:

原文地址:http://www.cnblogs.com/gaocong/p/5845594.html

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