Equivalent of LIMIT and OFFSET for SQL Server?

前端 未结 16 1970
天命终不由人
天命终不由人 2020-11-22 06:07

In PostgreSQL there is the Limit and Offset keywords which will allow very easy pagination of result sets.

What is the equivalent syntax f

16条回答
  •  不思量自难忘°
    2020-11-22 06:42

    -- @RowsPerPage  can be a fixed number and @PageNumber number can be passed 
    DECLARE @RowsPerPage INT = 10, @PageNumber INT = 2
    
    SELECT *
    
    FROM MemberEmployeeData
    
    ORDER BY EmployeeNumber
    
    OFFSET @PageNumber*@RowsPerPage ROWS
    
    FETCH NEXT 10 ROWS ONLY
    

提交回复
热议问题