What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?
This is a duplicate of the 2012 old SO question: efficient way to implement paging
FROM [TableX] ORDER BY [FieldX] OFFSET 500 ROWS FETCH NEXT 100 ROWS ONLY
Here the topic is discussed in greater details, and with alternate approaches.