Yup - thats the problem - the whole query ran within 1 ms - so the random
number generated for each record was the same throughout the length of the
query...
this is actually documented in SQL server books online:
|When you use an algorithm based on GETDATE to generate seed values, RAND
can still generate |duplicate values if the calls to RAND are made within
the interval of the smallest datepart used |in the algorithm. This is
especially likely if the calls to RAND are included in a single batch.
|Multiple calls to RAND in a single batch can be executed within the same
millisecond, which is |the smallest increment of DATEPART. In this case,
incorporate a value based on something other |than time to generate the seed
values.
So I cant see how in this situation you could order by random...
-----Original Message-----
From: Brian Hogue [mailto:[EMAIL PROTECTED]]
Sent: 22 May 2001 20:33
To: SQL
Subject: Re: [Fw: order by random]
Daniel -
There were some articles on this a few years ago. Most Random functions are
not really random. The sequence is so
long that it appears random to most people.
It sounds like your issue is that seed, or the starting point, is always the
same. Try using the seconds or
milliseconds of the current time as the seed. That is what many seeds used
to use.
-brian
Daniel Lancelot wrote:
> I tried to do something similar in SQL, but found that the rnd() function
is
> not random enough - I.E. they were ordered in the same order each time. I
> also tried using getdate() as the seed, but as the whole query ran within
1
> ms, the results were still not random.
>
> If anyone has done this sucessfully (i.e - different results each time
they
> run) I would be interested...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists