select [Uid],[Usname],[Uname],[Urole],[Upicture] from Us
create proc Upage
(
@pageindex int, ---当前页
@pagesize int, ---显示几条
@pagecount int out, ---总条数
@name varchar(50) ---查询名称参数
)
as
---判断有没有查询的参数
if(@name is null)
begin
---查询总记录数
select @pagecount=COUNT(*) from Us;
select * from(select ROW_NUMBER() over(order by Usname)as num, [Uid],[Usname],[Uname],[Urole],[Upicture] from Us ) temptable where num between ((@pageindex-1)*@pagesize+1) and (@pageindex*@pagesize)
end
else
begin
---查询总记录数
select @pagecount=COUNT(*) from Us where Usname like '%'+@name+'%';
select * from(select ROW_NUMBER() over(order by Usname)as num, [Uid],[Usname],[Uname],[Urole],[Upicture] from Us where Usname like '%'+@name+'%') temptable where num between ((@pageindex-1)*@pagesize+1) and (@pageindex*@pagesize)
---where num between((页码-1)*几条+1) and (页码*几条)
end
(
@pageindex int, ---当前页
@pagesize int, ---显示几条
@pagecount int out, ---总条数
@name varchar(50) ---查询名称参数
)
as
---判断有没有查询的参数
if(@name is null)
begin
---查询总记录数
select @pagecount=COUNT(*) from Us;
select * from(select ROW_NUMBER() over(order by Usname)as num, [Uid],[Usname],[Uname],[Urole],[Upicture] from Us ) temptable where num between ((@pageindex-1)*@pagesize+1) and (@pageindex*@pagesize)
end
else
begin
---查询总记录数
select @pagecount=COUNT(*) from Us where Usname like '%'+@name+'%';
select * from(select ROW_NUMBER() over(order by Usname)as num, [Uid],[Usname],[Uname],[Urole],[Upicture] from Us where Usname like '%'+@name+'%') temptable where num between ((@pageindex-1)*@pagesize+1) and (@pageindex*@pagesize)
---where num between((页码-1)*几条+1) and (页码*几条)
end