How To … Rotating Header Image

Implement pagination with SQL Server 2005

With the new row_number() feature of the MS SQL Server 2005, now it’s very easy to implement pagination: get data rows page by page to avoid the retrieve too much data at same time. The new feature it’s very similar to the Oracle ROWUM.
The prepare statement could be like the follow:

SELECT * FROM ( SELECT row_number() OVER (ORDER BY id) as resultNum, id FROM table_name) as numberResultsWHERE resultNum  BETWEEN ? AND ?

More information here.

Technorati Tags: ,

4 Comments

  1. aruntyagi says:

    Tell me in details how to Implement Pagination with code

  2. aruntyagi :Tell me in details how to Implement Pagination with code

    Hi Aruntyagi……

    Please find the code implementaion.

    Ramesh.

  3. I think that is not easy, but it’s what we have. Easy it’s the way that MySQL do, like example

    SELECT * FROM myTable LIMIT ? OFFSET ?

    That is beautiful Query, with a sintax very easy to read. I hope that Microsoft improve this feature in the next versions.

Leave a Reply