真正的分页存储过程
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
天道酬勤,厚积薄发。
君子之行,静以修身,俭以养德。
非淡泊无以明志,非宁静无以致远。
如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。