Here, you will learn how to use custom paging in SQL Server, using OFFSET-FETCH clause.
- CREATE PROC Test_Paging
- @Pagenumber INT =0,
- @Pagesize INT=10
-
- AS
-
- BEGIN
-
- SELECT Row_number() OVER ( ORDER BY UserID DESC ) [RowNo] ,
- FirstName,LastName,EmailID
- FROM Employee (NOLOCK)
-
- ORDER BY UserID
-
- OFFSET @Pagenumber * @Pagesize ROWS
-
- FETCH NEXT @Pagesize ROWS ONLY;
-
- END;