SQL Server - 创建分页存储过程
--------------------------分页存储过程-------------------------- --创建 create proc usp_pageScore @page int, --页数 @count int, --条数 @sumPage int output --总页数 as begin --获取总页数,CEILING表示向上取整 set @sumPage = (CEILING((select count(*) from ScoreTest) * 1.0 / @count)); select * from (select 编号 = ROW_NUMBER() over(order by Id), * from ScoreTest) t where t.编号 between (@page - 1) * @count + 1 and @page * @count; end; --调用 declare @t int exec usp_pageScore 5, 5, @t output select @t --删除 drop proc usp_pageScore --------------------------分页存储过程结束------------------------
作者:Jeremy.Wu
出处:https://www.cnblogs.com/jeremywucnblog/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。