In PostgreSQL there is the Limit and Offset keywords which will allow very easy pagination of result sets.
What is the equivalent syntax for SQL Server?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The equivalent of
LIMITisSET ROWCOUNT, but if you want generic pagination it’s better to write a query like this:The advantage here is the parameterization of the offset and limit in case you decide to change your paging options (or allow the user to do so).
Note: the
@Offsetparameter should use one-based indexing for this rather than the normal zero-based indexing.