Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Maintain Paging of Random Results

Author  Topic 

websthegame
Starting Member

1 Post

Posted - 2005-03-11 : 02:48:20
I am sure this is the place for a solution.

I need to query a table of holiday properties, return all matching properties and display, in a random order, 10 per page and provide a paging method (asp vbscript web site).

I need to keep this initial random sort order while paging until the search is modified when the order can change.

One solution i have used is to write the results to and XML file and use that as the datasource until a new search is made (requires session tracking).

Just thought that there may be a better way to do this using SQL server?

Nick

sureshot
Yak Posting Veteran

72 Posts

Posted - 2005-03-11 : 03:11:19
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=5958 - check out the last post.

quote:
Originally posted by Channing_Jones

You can also use the Sine-function to generate a nearly-random sequence:

"select top 10 * from myTable order by Sin(UnitID * Rand() * 1000)"

With UnitID being a unique value for each record. The 1000 ensures that the numbers are not within the same 2pi-period.




The above made me think of an idea. I haven't tried this, but perhaps you can generate your seed for Rand() in ASP and then pass it into your query if you want to keep the same order. There are tons of articles online about setting up paging and you can try modifying any number of these with this idea.
Go to Top of Page
   

- Advertisement -