PAGING (分頁)
--@PageNumber代表第幾頁
--@PageSize代表每頁要顯示幾筆
CREATE PROCEDURE spGetRowsByPageNumberAndSize
(
@PageNumber INT ,
@PageSize INT
)
AS
BEGIN
SELECT *
FROM Book
ORDER BY BookID
OFFSET ( @PageNumber - 1 ) * @PageSize ROWS
FETCH NEXT @PageSize ROWS ONLY;
END;
GO
EXECUTE spGetRowsByPageNumberAndSize 4, 10;
GO