Last post May 23, 2007 03:50 PM by jamesqua
May 23, 2007 02:27 PM|jamesqua|LINK
In the past i have always used a temporary table to implement paging on the sql server sid but I recently thought of a simlper way to do it. For examlpe if you wanted to get records 11 through 21 you would do this
Select top 10 * from employees where employeeid not in(select top 10 employeeid from employees order by employeeid) order by employeeid
You would have to use dynamic sql to change the top n inside the subquery but I still feel this is less of a hassle than using a temp table.
May 23, 2007 03:32 PM|benpyle|LINK
You could also (in SQL Server 2005)
With Records AS
SELECT ROW_NUMBER() OVER (ORDER BY SomeColumn) AS RowNum,
(SELECT COUNT(*) FROM Records) AS TotalRows
WHERE RowNum BETWEEN @StartingRow AND (@StartingRow - 1) + @PageSize
May 23, 2007 03:50 PM|jamesqua|LINK
Yeah, I know 2005 has support for this, but the above post is the best thing I've come up with for 2000.