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

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select Random Records

Author  Topic 

oahu9872
Posting Yak Master

112 Posts

Posted - 2007-11-08 : 16:53:45
I have large data sets where I would like to pick out random records. For example I might have a set of 5000 employee profiles and I want to write a select statement that picks out a random 50 of the 5000 records. Any ideas?

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-08 : 16:57:06
SELECT TOP 50 *
FROM YourTable
ORDER BY NEWID()

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

oahu9872
Posting Yak Master

112 Posts

Posted - 2007-11-08 : 16:59:48
Thanks
Go to Top of Page
   

- Advertisement -