Tuesday, May 29, 2007

Next N records, paginated sql server results

I have several places on my web site where I let the user page through search results and recordsets. Usually this is inneficient because your return all resulsts and essentially hide everything but the rows they want to see. This is very inneficient and the only examples of doing this correctly were difficult at best.

Well, with SQL Server 2005 there is a new feature - ROW_NUMBER() that makes this simpoler to implement. Not 100% intuitive but I was able to figure it out. The following link is a good tutorial that helped me:

http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx

No comments: