.net(C#)求一个MSsql分页的存储过程
来源:百度知道 编辑:UC知道 时间:2024/05/25 13:34:58
.net(C#)求一个MSsql分页的存储过程
可以用的.包括调用实例
userinfo表
字段:ID,username,company,email
我试了,好像不行啊.
请各路神仙都来帮我一把啊
可以用的.包括调用实例
userinfo表
字段:ID,username,company,email
我试了,好像不行啊.
请各路神仙都来帮我一把啊
CREATE procedure pageer_rnewlist
(@pagesize int,
@pageindex int,
@docount bit,
)
as
set nocount on
if(@docount=1)
select count(*) from userinfo
else
begin
declare @indextable table(id int identity(1,1),ID int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(ID)
select ID from useinfo where order by ID desc
select O.* from userinfo O,@indextable t where O.ID=t.ID
and t.ID>@PageLowerBound and t.ID<=@PageUpperBound order by t.ID
end
set nocount off