I did a quick and functional gambiarra:
I created a VIEW with SELECT below without conditioning Where:
SELECT row_number() OVER (ORDER BY p.idprod ASC) as paginacao, [demaiscampos] FROM [tabela]
Then I called the view using:
SELECT paginacao, [demaiscampos] FROM [tabela] WHERE paginacao BETWEEN [reginicial] AND [regfinal]
This way I can page the query without overloading the bank’s processes.
There is also the method:
DECLARE @PageNumber AS INT, @RowspPage AS INT
SET @PageNumber = 2
SET @RowspPage = 5
SELECT * FROM (
SELECT ROW_NUMBER() OVER(ORDER BY ID_EXAMPLE) AS NUMBER,
ID_EXAMPLE, NM_EXAMPLE, DT_CREATE FROM TB_EXAMPLE
) AS TBL
WHERE NUMBER BETWEEN ((@PageNumber - 1) * @RowspPage + 1) AND (@PageNumber * @RowspPage)
ORDER BY ID_EXAMPLE
and also this:
--CREATING A PAGING WITH OFFSET and FETCH clauses IN "SQL SERVER 2012"
DECLARE @PageNumber AS INT, @RowspPage AS INT
SET @PageNumber = 2
SET @RowspPage = 10
SELECT ID_EXAMPLE, NM_EXAMPLE, DT_CREATE
FROM TB_EXAMPLE
ORDER BY ID_EXAMPLE
OFFSET ((@PageNumber - 1) * @RowspPage) ROWS
FETCH NEXT @RowspPage ROWS ONLY;
Not as simple as Mysql, but simple for MSSQL
– Dorathoto
I believe that this code works in sql server 2000, if you know any other way, leave your answer in this question: paging sql server 2000 records
– rray
Actually "limit 50, 100" means "skip" 50 and "list" 100, that is, from record 51 to 150
– Vanderlei Pires