I want get n-th to m-th records in a table, what\'s best choice in 2 below solutions:
Solution 1:
SELECT * FROM Table WHERE ID >= n AND ID <
The 2nd answer is your best choice. It takes into account the fact that you could have holes in your ID column. I'd rewrite it as a CTE though instead of a subquery...
;WITH MyCTE AS
(SELECT *,
ROW_NUMBER() OVER (ORDER BY ID) AS row
FROM Table)
SELECT *
FROM MyCTE
WHERE row >= @start
AND row <= @end