--SQL Server 2012及以上版本 declare @pageIndex int = 0, @pageSize int = 20 select field1, field2
from table1
where 1=1 order by field1 offset @pageIndex rows fetch next @pageSize rows only
--SQL Server 2005及以上版本
with table1Pages as (
select field1, field2,Row_Number() over (order by field1) as rowNumber
from table1
where 1=1
order by field1
)
select field1, field2 from tableNamePages
where rowNumber > @pageIndex*@pageSize and rowNumber <= (@pageIndex + 1)* @pageSize