您的位置:首页 > 其它

真正的分页存储过程

2013-03-24 14:03 127 查看
IF OBJECT_ID('jjp_CategoryList_Get') IS NOT NULL
    DROP PROCEDURE jjp_CategoryList_Get;

GO

CREATE PROCEDURE jjp_CategoryList_Get
(
    @pageIndex int,
    @PageSize int,
    @Records int output
)
AS
begin
    with tmpTable as
    (
    select id, c1, c2 , row_number() over( order by id) as rownum from dbo.t1
    )
    select *  from tmpTable where  rownum between (@pageIndex-1)*@PageSize+1 and @PageIndex*@PageSize;
    select @Records=count(*) from dbo.t1;

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: