How I can implement paging in SQL Server database it has no LIMT keyword like mysql?
Asked
Active
Viewed 115 times
1
-
1possible duplicate of [Paging SQL Server 2005 Results](http://stackoverflow.com/questions/2840/paging-sql-server-2005-results) – Aug 23 '10 at 11:34
2 Answers
-1
It doesn't use LIMIT, but you can use TOP:
SELECT TOP 10 *
FROM foo
WHERE whateverPagingID >= 650 /* or whatever the last page started with */
ORDER BY pagingID;

Dave Markle
- 95,573
- 20
- 147
- 170
-
2This only gets the first page. You need to use the ROW_NUMBER function – Tim Rogers Aug 23 '10 at 10:41
-
Implicit in my answer was that you're keeping the last pagingID (650 in this case) and supplying it to the WHERE clause. Sorry if it was unclear. – Dave Markle Jan 09 '11 at 14:09