添加测试数据
declare @i int
set @i=1
while(@i<500)
begin
insert into [fenye].[dbo].[User] (name) values('name'+ convert (varchar(10),@i))
set @i=@i+1;
end
创建存储过程方便调用
create procedure [dbo].[P_LoadPageData]
--参数
@pagesize int,
@pageIndex int,
@total int out
as
--代码
select top (@pageSize) * from [fenye].[dbo].[User] where userId not in
(
select top ((@pageIndex-1)*@pageSize) userId from [fenye].[dbo].[User] order by userId
)order by userId
测试存储过程 exec P_LoadPageData 3,1,499