Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi!

I want to select(Name) Randomly from Table. What is simple code.
Posted
Updated 25-Aug-11 22:56pm
v2

This link[^] provides a few different ways to do this.
 
Share this answer
 
v2
Comments
Herman<T>.Instance 26-Aug-11 4:56am    
good link ;)
LebneizTech 26-Aug-11 4:58am    
Thank You. It is very simple.
see here: http://www.petefreitag.com/item/466.cfm[^]

this was a 20 second google search
 
Share this answer
 
Comments
Simon Bang Terkildsen 26-Aug-11 4:57am    
20 second? you're getting slow :P +5
Herman<T>.Instance 26-Aug-11 4:58am    
sorry for being slow ;) it is friday and I have weekend on my mind
Use following query

SQL
SELECT TOP 1 Name FROM  Table ORDER BY NEWID()


NEWID will return you a uniqueidentifire.
 
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