Click here to Skip to main content
15,902,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a table in sql 2005 named [friend]
Id FId
1 2
1 3
1 5
2 3
2 4
3 4
3 5

I am able to select all fid successfully but they are ordered in descending by id. Is their any possibility that i can make these FId appear randomly by query.
i.e,
Every time refresh the page the FId displaying position should be changed.
Posted
Updated 5-Apr-11 4:26am
v2
Comments
wizardzz 5-Apr-11 10:26am    
Edited for spelling, punctuation.

use
Order By NewID()
 
Share this answer
 
Comments
naveen.0nick 5-Apr-11 11:34am    
Thanx
You can use NEWID function for this. For example
SELECT TOP 1 FID
FROM Friend
ORDER BY NEWID()
 
Share this answer
 
Comments
RaviRanjanKr 5-Apr-11 10:37am    
Nice Answer! My 5 :)
Wendelius 5-Apr-11 14:17pm    
Thank you :)
naveen.0nick 5-Apr-11 11:35am    
Thanx
Wendelius 5-Apr-11 14:18pm    
You're welcome :)
See TABLESAMPLE[^]
 
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