It's normally ok.. The only problem is that it may not work properly on
some configurations.
(probably on computers not connected to network due to guid algorithm)

Also it's not the fastest method.. Depending on what you need and nature
of data you can 
find a faster one.. 

However should work perfect on most of sql installations with reasonably
big databases.



-----Original Message-----
From: Andy Hall [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 03, 2002 4:58 PM
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] Slightly OT: Returning a random row from SQL
Server


Albert,

I just gave your code a try and it seemed to do the trick. It pulls out
a different row every time which is what I need.

What are the drawbacks of this method?

Cheers,

Andy.



----- Original Message -----
From: "Albert Popkov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 03, 2002 4:47 PM
Subject: RE: [ cf-dev ] Slightly OT: Returning a random row from SQL
Server


>
> Easiest (but not the best):
> select top 1 newid(), * from mytable order by 1
>
> ------------------------
> Albert Popkov
> i-CD Publishing (UK) Ltd
> www.192.com
> [EMAIL PROTECTED]
>
>
> -----Original Message-----
> From: Andy Hall [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 03, 2002 4:03 PM
> To: [EMAIL PROTECTED]
> Subject: [ cf-dev ] Slightly OT: Returning a random row from SQL 
> Server
>
>
> Hi,
>
> I need to retrieve a random row from a table. Although I could get the

> whole recordset and select one in CF, I would prefer to only return 
> the single row of data I need.
>
> Can anyone give me a neat method of getting SQL Server 7 to get one 
> random row?
>
> I have got a random number based on the number of records, but unless 
> I can access that row directly (like in CF -  queryname.columnname[x])

> then I dont know of a way to get the row. Does anyone know if I can do

> this?
>
> Any help appreciated
>
> Andy Hall.
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED] For 
> human help, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED] For 
> human help, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] For
human help, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]


Reply via email to