TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

SQL Server 2005: ROW_NUMBER Function

A Scott Guthrie post prompted me to take a close look at the SQL Server 2005 function:  ROW_NUMBER(). Sure enough, this ability will greatly simplify code similar to the GridView/ObjectDataSource paging example I wrote the other day.

WITH PagedOrders as
    (
      select ROW_NUMBER() OVER(order by o.OrderID) as RowNumber,
            o.OrderID,
            o.CustomerID,
            o.OrderDate
      from orders o
    )

select *
from PagedOrders
where RowNumber between 25 and 50

SQL Server 2005 rocks!!!

Oh, and it's not that I'm not excited about ajax or atlas. Be sure to read Scott's post in full. :-)


Digg!

posted on Sunday, January 01, 2006 11:46 AM

Feedback

No comments posted yet.