Random record, display at random time 
Author Message
 Random record, display at random time

I have a (sql) stored procedure to get one random trivia question
record a day but I want to display it only once a day
at a random time between 8:00 and 5:00.  I am thinking
that I need to pick a random time and then store the time
as tdisplayed in the table and then tell the web
page to display it only if the time the page is requested is
after that time in the table (tdisplayed).  Or should I be looking
for a Dreamweaver Ultrdev extension that does this? I am not sure
how to code for random time and have searched high and low in
the newsgroups, with no luck.  If anyone has an idea of how
to do this, I would be very grateful.  Thanks!!

-Caroline

My stored procedure for the random record is as follows:

CREATE PROCEDURE spcc_trivia_getrecord  AS



-- Get the number of records in the trivia table

-- Select a random number between 1 and the number
-- of records in the trivia table

-- Select the record from the trivia table with the
-- ID equal to the random number selected
Select mquestion, triviaid From Trivia

and trivia.tdisplayed = '1899-12-30'
GO



Sun, 17 Oct 2004 03:50:42 GMT
 Random record, display at random time

Caroline,

Using DATEADD will change coding for a random time, to coding for a random
number.

You could have a daily SQL Agent job set to run at 08:00
and use WAITFOR DELAY.

Or have the 1st execution generate the random time, and have the Job running
periodically, checking if GETDATE / CURRENT_TIMESTAMP is > yet.

Or if you are wanting to absolutely minimise server load, then have your
once a
day job generate a job to run at a random time.  You could use EXECUTE
for this, where most of the text you can get from <right><click> and script
in Enterprise Manager, on an existing job.

Regards
 AJ


Quote:
> I have a (sql) stored procedure to get one random trivia question
> record a day but I want to display it only once a day
> at a random time between 8:00 and 5:00.  I am thinking
> that I need to pick a random time and then store the time
> as tdisplayed in the table and then tell the web
> page to display it only if the time the page is requested is
> after that time in the table (tdisplayed).  Or should I be looking
> for a Dreamweaver Ultrdev extension that does this? I am not sure
> how to code for random time and have searched high and low in
> the newsgroups, with no luck.  If anyone has an idea of how
> to do this, I would be very grateful.  Thanks!!

> -Caroline

> My stored procedure for the random record is as follows:

> CREATE PROCEDURE spcc_trivia_getrecord  AS



> -- Get the number of records in the trivia table

> -- Select a random number between 1 and the number
> -- of records in the trivia table

> -- Select the record from the trivia table with the
> -- ID equal to the random number selected
> Select mquestion, triviaid From Trivia

> and trivia.tdisplayed = '1899-12-30'
> GO



Sun, 17 Oct 2004 09:31:37 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Display records from a Recordset at random

2. Display records from a Recordset at random

3. Display records in random order

4. Displaying Records at Random

5. How to selectively display random records??

6. Displaying Random Records

7. Solution Binding (WAS: Displaying Random Records)

8. Display records from a Recordset at random

9. random numbers that are more random

10. SQL 7.0 Random function, does not work like SQL 6.5 Random function

11. Selecting 1 random row from each of n random groups

12. how to display results in random order


 
Powered by phpBB® Forum Software