Thread: SQL Paging (Find page) help
01-08-13, 04:27 #1Registered User
- Join Date
- Jan 2013
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.
01-08-13, 09:56 #2Resident Curmudgeon
Provided Answers: 54
- Join Date
- Feb 2004
- In front of the computer
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.
-PatPIn theory, theory and practice are identical. In practice, theory and practice are unrelated.