Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2013
    Posts
    3

    Unanswered: SQL Paging (Find page) help

    Apologies i had posted this in the wrong forum and have moved it to here!!

    I have been looking for a solution to a problem for the past week and am currently pulling my hair out and hoping someone can help me. I have implemented a stored procedure in SQL Server 2008 to handle server side paging. The procedure is passed a startRowIndex and a maximum number of rows required, and then uses the ROWCOUNT to retrieve the required rows. This may not be efficient but works (any suggestions of better ways welcome).

    But next when a record is added or amended in the Front end C# application I have designed, I need to find what page that record sits in, and display that page to the user, still allowing them to page ether way from that page. Every were I have looked has focused on the Primary key, which in an ideal world would be great as you would know were in the table the record sat. But my application will allow deletes meaning there will be gaps in the sequence, plus I need the pages ordered by another column (Hence have a Clustered index on that column).

    Can anyone help me, I Know it is possible as I currently use a system at work that implements this behavior…

    I would like to say thank you in advance.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    For small-ish result sets (up to a few thousand rows), I'd probably use the OVER Clause (Transact-SQL) but beware if your result sets get large... Paging through a bazillion pages is never a good idea for the user, and it performs poorly too.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •