SELECT ProductID, Name, ROW_NUMBER() OVER(ORDER BY ProductID) FROM Product WHERE ROW_NUMBER() OVER(ORDER BY ProductID) BETWEEN 11 AND 20
SELECT ProductID, Name, ROW_NUMBER() OVER(ORDER BY ProductID) AS RowNumber FROM Product WHERE RowNumber BETWEEN 11 AND 20
WITH PagingCTE AS ( SELECT ProductID, Name, ROW_NUMBER() OVER(ORDER BY ProductID) AS RowNumber FROM Product ) SELECT ProductID, Name, RowNumber FROM PagingCTE WHERE RowNumber BETWEEN 11 AND 20
We could have also used a derived table instead of a CTE, but then I wouldn't have had an excuse to explain CTEs. :-)Now you have a back-end query to compliment an ASP.NET DataGrid control and it's paging functionality. Oh, and probably other uses, as well. ;-)
Remember Me
b, blockquote@cite, em, i, strike, strong, sub, sup, u
Powered by: newtelligence dasBlog 2.3.9074.18820
© Copyright 2012, Troy DeMonbreun
E-mail