OFFSET/FETCH Pagination:- With the help of these OFFSET and FETCH keywords inside a CTE I managed to build a SQL Stored procedure that was at least twice as fast in return times as the other average ones found on the internet. Here I'm sharing 2 examples to achieving the SQL filtering, sorting and paging . Both example are tested and working fine but I will recommend example 1 for you. Example 1, --[dbo].[usp_GetemployeeCodes] NULL, 1, 10, 'employee_code', 'DESC' CREATE PROCEDURE [dbo] . [usp_GetEmployeeCodes] ( /* Optional Filters for Dynamic Search*/ @SearchCode NVARCHAR ( 50 ) = NULL, /*– Pagination Parameters */ @PageNo INT = 1 , @PageSize INT = 15 , /*– Sorting Parameters */ ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers