The newID() function generates a new identifier for the rows in the table. So when you order by newID(), it is ordering the records in the table by a new database generated and unique ID that will change with each query. The select top 20 is simply limiting the return to 20 records. It will not necessarily be the first 20 records in the table, rather the first 20 records with respect to the new identifier. Since the identifier will change each time, the 20 returned records will change each time.
The merits if the "randomness" of the newID() function is debatable. But for all intents and purposes you will get "random" results. I'm pretty sure this is the preferred method of getting random records from a table in SQL Server. Steve -----Original Message----- From: Jeff Small [mailto:[EMAIL PROTECTED] Sent: Monday, April 02, 2007 10:45 AM To: CF-Talk Subject: Re: How to Random Pick records from a 10k record table via SQL > Just selecte top 20 like russ said and order by rand() instead of newId() Correct me if I'm wrong, by all means, but selecting the "top 20" from 10,000 records is about as far from "random" as you can be, isn't it? Won't you have to: 1. randomly select a record with some kind of rand() function of your choosing. (either your SQL or CF) 2. check to ensure that you haven't already selected that record 3. if duplicate entry, go back to 1 4. repeat until 20 records are selected 5. stop I mean, it's a little more complicated to *really* randomly select 20 records from 10,000, but it's certainly not hard with some kind of iteration over that process, right? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create Web Applications With ColdFusion MX7 & Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:274315 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

