Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Site Related Forums
 Article Discussion
 Article: Returning a Single Random Row

Author  Topic 

Ask SQLTeam Question

0 Posts

Posted - 2000-09-23 : 12:11:01
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.

Starting Member

36 Posts

Posted - 2002-03-28 : 14:50:14

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

Jedi Yak

2489 Posts

Posted - 2002-03-28 : 15:57:47
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.


Go to Top of Page


468 Posts

Posted - 2002-03-28 : 16:00:27
My mind is blown . . .

Go to Top of Page

SQL Gigolo

1157 Posts

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


Go to Top of Page

- Advertisement -