alter PROCEDURE Term4GetPagedData
@pageIndex int = 1,--页码
@pageSize int
=10,--页容量
@sMid int,
@rowCount float output,--输出 总行数
@pageCount float
output--输出 总页数
AS
BEGIN
select @rowCount = COUNT(sId) from Strategy
where sMid=@sMid --求总行数
set @pageCount= CEILING(@rowCount / @pageSize)--使用
天花板 函数,将 带小数的数值,加1 去小数
select * from(select row_number() over(order by sId)
as rownum ,mn.*,n.stName from(Strategy as mn inner join StrategyType as n on
mn.sMId=n.stId ))
as temp where temp.rownum
>(@pageIndex-1)*@pageSize and temp.rownum <=@pageIndex*@pageSize and
sMId=@sMid
END
GO
declare @rc int,@pc int
exec Term4GetPagedData 1 ,10, 1 , @rc output,@pc
output
select @rc,@pc
select * from Strategy
SQL带条件,联合,分页查询语句,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/lxclqy/p/3779158.html