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 ‘%‘[email protected]+‘%‘;
select * from(select ROW_NUMBER() over(order by Usname)as num, [Uid],[Usname],[Uname],[Urole],[Upicture] from Us where Usname like ‘%‘[email protected]+‘%‘) temptable where num between ((@pageindex-1)*@pagesize+1) and (@pageindex*@pagesize)
---where num between((页码-1)*几条+1) and (页码*几条)
end
原文地址:https://www.cnblogs.com/huosanpie/p/9967425.html