Paging in Sql Server

vishalneeraj-24503
Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 234
Below query will show 10 record at a time.
DECLARE @PageSize int = 10, @PageNumber int = 1;
SELECT *
FROM employee_master
ORDER BY employee_id
OFFSET (@PageNumber-1)*@PageSize ROWS
FETCH NEXT @PageSize ROWS ONLY;

If we want to fetch next 10 records i.e. from 11-20,then set @PageNumber = 2 and so on.

Comments or Responses

Login to post response