SQLUSA

Microsoft SQL Server 2000

Best Practices

 

How to get random results from SELECT?

 

To get the select results sorted randomly, you have to use the newid() function. This is an example:

 

select top 10 * from PhotoList order by newid()

 

It will return random selection from the entire select set for each consecutive execution.

 

Best in the World in SQL Server Training
 
SQLUSA.com Home Page