locked
Search & Sorting RRS feed

  • Question

  • User-1499457942 posted

    Hi

     I have below Stored procedure and i want to add Search/Sorting functionality

    ALTER PROCEDURE [dbo].[sp_GetEmployeesPageWise]
          @PageIndex INT = 1
          ,@PageSize INT = 10
          ,@RecordCount INT OUTPUT
    AS
    BEGIN
          SET NOCOUNT ON;
          SELECT ROW_NUMBER() OVER
          (
                ORDER BY A.[EmployeeID] ASC
          )AS RowNumber
          ,A.[EmployeeID],A.[FullName]
          INTO #Results
          FROM dbo.Employee A     
         
          SELECT @RecordCount = COUNT(*)
          FROM #Results
               
          SELECT * FROM #Results
          WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
         
          DROP TABLE #Results
    END

    Thanks

    Saturday, November 10, 2018 8:54 AM