Hi,


The only (potential) problem with NEWID is that it does a tablescan, and
hence can be very expensive.


AFAIK, It only works properly in SQL 2000 too.


Ian

-----Original Message-----
From: Michael Kear [mailto:[EMAIL PROTECTED]
Sent: 04 August 2004 15:36
To: CF-Talk
Subject: RE: tip of the day

In SQLServer,  the syntax to get a random record is:

SELECT TOP 1 * FROM tablename Order By NEWID()

In SQLServer, the NEWID() function gives the random record.

Cheers
Mike Kear
Windsor, NSW, Australia
AFP Webworks
http://afpwebworks.com

________________________________________
From: Ewok [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 4 August 2004 9:40 AM
To: CF-Talk
Subject: Re: tip of the day

well there are a couple of ways to get a random record...
as long as ou are not using access there is a RAND() function to do it...
something like this if i remember correctly

select * from table order by Rand() limit 1

that SHOULD return 1 random record everytime its ran.

[snip]
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to