Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is it possible to retrieve the records randomly
please specify
Posted

SQL
select top 10 * from  yourtable order by NEWID()
 
Share this answer
 
v3
Comments
sachin10d 21-Oct-11 2:20am    
Good One!!!
Mukund Thakker 21-Oct-11 2:24am    
This is the best solution so far...
Toniyo Jackson 21-Oct-11 2:29am    
Good solution, 5!
This will help you

sql-server-random-number-generator-script-sql-query/[^]

use the value extracted to retrieve records randomly
 
Share this answer
 
v2
Try this

SQL
select top 10 * from (
SELECT ABS(CAST(NEWID() AS binary(6)) %1000) + 1 randomNumber,*
FROM yourTableName)t order by randomNumber
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900