SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: Returning a Single Random Row
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 09/23/2000 :  12:11:01  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Earlier we published an article on quickly creating a sequential number. In this article we'll use that technique to quickly select one random record from a table. We'll even cover assigning a weight to each record. Can someone say banner ads?

Article Link.

SteveMc
Starting Member

United Kingdom
3 Posts

Posted - 08/22/2001 :  06:25:19  Show Profile  Send SteveMc an ICQ Message  Reply with Quote
That is an ingenius bit of trickery!

With a bit of tweaking I managed to use this method to set up a random data generator for a temperature sensor, based on a table containing outline values, your article has probably saved me a days work there 8)...

Go to Top of Page

motokevin
Starting Member

36 Posts

Posted - 03/28/2002 :  14:50:14  Show Profile  Reply with Quote
Dudes,

I found a method to pull a single random row that is soooooo easy (I wish I'd thought of it.) No min/max or Ubound/lbound or averaging.

Select top 1 [data you want from row]
from [table or whatever]
Order By NEWID()



Go to Top of Page

MichaelP
Jedi Yak

USA
2489 Posts

Posted - 03/28/2002 :  15:57:47  Show Profile  Visit MichaelP's Homepage  Reply with Quote
OMG, that works!! Now that is an elegant solution!
Now, I'm not sure on how random it really is, but it seems pretty random in my testing.

Michael


Go to Top of Page

Jay99
Constraint Violating Yak Guru

USA
468 Posts

Posted - 03/28/2002 :  16:00:27  Show Profile  Reply with Quote
My mind is blown . . .

http://www.microsoft.com/sql/using/tips/development/queryresults.asp

Jay
<O>
Go to Top of Page

JustinBigelow
SQL Gigolo

USA
1157 Posts

Posted - 03/28/2002 :  17:12:01  Show Profile  Reply with Quote
Jay, thanks for the link I read thru all those tips and found some cool info.

Justin

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000