Sqlserver存储过程分页

create proc Paing_6
(
 @pageIndex int,
 @pageSize int,
 @name varchar(50),
 @count int output
)
as
begin
declare @con varchar(100)='%'+@name+'%'
select * from
(
select ROW_NUMBER() over(order by id) as NO,* from V_stu
where
sName like @con
)
as t where t.NO between @pageSize*(@pageIndex-1)+1 and @pageIndex*@pageSize  
select @count = count(*) from
(
select ROW_NUMBER() over(order by id) as NO,* from V_stu
where
sName like @con
)
as t
declare @k float
set @count=CEILING(convert(float,@count)/convert(float,@pageIndex)) 
end
go
declare @k int
exec Paing_6 2,10,'啊',@k output
select @k
 

猜你喜欢

转载自www.cnblogs.com/yinyongle/p/10530606.html