HOME | CONTACT
 
Products 
Download 
Purchase 
Company 
Contact 
  View Shopping Cart Email Us
How to do a truly random draw of records from a SQL Server table
 
 

The problem:

You need to pick certain number of rows from a SQL Server table in a truly random maner without favoring one row over another. For example, you have a table where each row represents a chance to win something and you have been tasked with the picking of 10 winning entries (truly randomly).

The solution

The solution is very simple considering the fact that newid() generates as close to truly random numbers as you can get. Simply run the following:
    select top 10 * from my_table order by newid()

Click here to go back to the SQL Server content index page.

 
Announcements
 
xSQL Profiler released - monitor multiple SQL Servers...
[more...]
 
 
Products
 
xSQL Bundle
xSQL Object
xSQL Object Command Line
xSQL Data Compare
xSQL Data Command Line
xSQL Profiler
xSQL Documenter
xSQL Builder
xSQL SDK
RSS Reporter
Script Executor
Object Search
 
 
 
 
 
 
Testimonials
 
xSQL Builder provides us with everything we need to automate our database processes. Thanks to this our database update process is now 6 times faster.
- Phil H.
i2i Innovate to Integrate, UK
 
This (RSS Reporter) is a very good mashup of traditional sql server management and leading-edge information access!
- Robert H.
U.S. Xpress Enterprises
 
...It also features the best (and simplest) way to move objects and data via sql script I’ve ever seen. I’m hooked.
- Steve F.
Creative Plumbing, GA
 
We have tested ... and compared it with 6 other products. We preferred xSQL Data Compare...
- Han van der H.
RIVM LTR Laboratory, The Netherlands
 
 
| Contact | Privacy Policy | Terms Of Use | Site Map |
©Copyright 2003-2007 xSQL Software. All Rights Reserved.