SQL server 的具体问题,求答案和讲解~谢过~~(新人)
sql server中用存储过程实现一下数据视图的分页函数,假设每页显示10行。
IDName
2Bod
1Barry
9Tina
[最优解释]
create function F_page(@page int)
returns @tb table(id int,name varchar(20))
as
begin
insert into @tb
select id,name
from (
select id,name,ceiling(ROW_NUMBER() over(order by id)/10.0) as page from Tablename) as a
where page=@page
return;
end
[其他解释]
create PROCEDURE getPersonInfo
-- Add the parameters for the stored procedure here
(
@currentpage int
)
AS
BEGIN
SET NOCOUNT ON;
SELECT TOP 10 * FROM PersonInfo WHERE id> ANY (select TOP (10*(@currentPage-1)) id FROM PersonInfo ORDER BY id)
END