 |
| SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 30th, 2003, 11:20 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Retreive 90th -100th rows from a query
I have a set of tables with almost 2,00,000 records each.
I want to search for a particular condition using JOIN and
THEN retreive only 20th - 30th record; and not all.
I can use TOP 10 to get 1-10th record; but that doesn't
solve my purpose as I display the records in a Webpage
with 10 records each page; and when the user is in the 9th
page i got to display 90th - 100th record; and so on.
DONT want to use cursors.
Is there any hidden row returned by SQL 2000 which
contains Serial Number; i.e the record position which
helps me to achieve it.
|
|

November 30th, 2003, 12:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Take a look at this article: http://www.4guysfromrolla.com/webtech/062899-1.shtml
It describes custom paging using a Stored Procedure. The downside of the solution explained in this example is that a copy of the original data is made, every-time you call the procedure. No fun with 2,000,000 records ;) You could decide to create a permanent copy of the data, purely for your data navigation. Depending on the app and database you have, this may work pretty well or it may turn out to be a maintenance nightmare ;)
Take a look here: http://www.adopenstatic.com/experime...dsetpaging.asp for a discussion on various paging methods and their speed.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 30th, 2003, 12:50 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Is there a column which orders the data? If so, you might be able to use a technique where you SET ROWCOUNT equal to the number of rows you want to return (e.g. 10), or use the TOP clause, then construct a WHERE clause which selects all rows whose ordering column value is greater than a parameter. Start with the parameter value less than the smallest legal ordering value. When you execute the procedure that displays the first set of rows, remember the ordering value of the last row you displayed, and use this as the parameter for the next fetch. Repeat as necessary.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
|
|

December 1st, 2003, 03:07 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Jeff Mason
Is there a column which orders the data? If so, you might be able to use a technique where you SET ROWCOUNT equal to the number of rows you want to return (e.g. 10), or use the TOP clause, then construct a WHERE clause which selects all rows whose ordering column value is greater than a parameter. Start with the parameter value less than the smallest legal ordering value. When you execute the procedure that displays the first set of rows, remember the ordering value of the last row you displayed, and use this as the parameter for the next fetch. Repeat as necessary.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
Thanks Jeff.
I have a small Problem. If the user goes to 10th page by clicking the hyperlink from 2nd page, my last row displayed value would not help !!!
cheers,
Ramanuj
|
|
|

December 1st, 2003, 07:49 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Yes. Allowing the user to 'bounce around' makes thing much more difficult. I was assuming just a forward paging movement through the data. Sorry.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
|
|
 |