The simplest way is to use
TOP
instruction.
SELECT TOP (135) <Field_list>
FROM TableName
Please, see:
TOP (Transact-SQL)[
^]
If you would like to add row number, use
ROW_NUMBER()[
^] function.
SELECT TOP (135) ROW_NUMBER() OVER(ORDER BY <FieldName>) AS RowNo, <Field_list>
FROM TableName
You can set the limit of rows via using
ROW_NUMBER()
function.
SELECT *
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY <FieldName>) AS RowNo, <Field_list>
FROM TableName)
AS T
WHERE RowNo<=135
In the same way, you can fetch data from defined range, for example:
DECLARE @rFrom INT = 136
DECLARE @rTo INT = 170
SELECT *
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY <FieldName>) AS RowNo, <Field_list>
FROM TableName)
AS T
WHERE RowNo BETWEEN @rFrom AND @rTo
I call it: 'custom pagination' ;)