Paging is a common use case throughout client and web applications. In the real world, enterprise applications typically handle large amounts of data. Typically, Handle displays a large amount of data. You should load a small amount of data, then load the rest of the data based on user's needs. It's very useful to make your application faster.
For example, you can get 10 product rows from the Northwind database as below
DECLARE @PageNumber AS INT, @Rows AS INT SET @PageNumber = 1 SET @Rows = 10 SELECT* FROM Products ORDER BY ProductID OFFSET ((@PageNumber - 1) * @Rows) ROWS FETCH NEXT @Rows ROWS ONLY
Increase @PageNumber variable to get the next page. You can also create a stored procedure to receive the rows on each page
CREATE PROCEDURE sp_Product_GetPages ( @PageNumer INT, @Rows INT ) AS SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued FROM Products ORDER BY ProductID OFFSET ((@PageNumber - 1) * @Rows) ROWS FETCH NEXT @Rows ROWS ONLY