T-SQL has a random number generator so you could do a while loop against a
random number between 1 and the number of records. All you need to do is
specify the random seed using the date, SQL books online has a good example
of doing this, search for "rand"
       [EMAIL PROTECTED]
=---------------------------------------------------------------------------
--=

We are the music-makers,
  And we are the dreamers of dreams,
Wandering by lone sea-breakers,
  And sitting by desolate streams;
World-losers and world-forsakers,
  On whom the pale moon gleams:
Yet we are the movers and shakers
  Of the world for ever, it seems.

Arthur William Edgar O'Shaughnessy. 1844-1881

=---------------------------------------------------------------------------
--=
----- Original Message -----
From: "Nick Middleweek" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Friday, August 30, 2002 7:23 PM
Subject: Best way to select random record?


> Hello,
>
> I'd like to SELECT a random record from table.
>
> What's the best way of doing this?
>
> I'm thinking that I need to SELECT all ID's into an array, randomly choose
> an element and then do another SELECT ... WHERE ID = chosen_ID
>
>
> Can I do it in one operation?
>
>
> Thanks,
> Nick
>
>
> ---
> You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
> To unsubscribe send a blank email to
%%email.unsub%%
>
>


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to