.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Get random records from table in Sql Server

Posted By: Deco     Posted Date: September 16, 2010    Points:2   Category :Sql Server
how can i get 5 random records in table which has 1000 records,

every time i run the Query, i should get random records.

Please help me by proving the query

Responses
Author: Sunil Yadav       [Moderator]   Accepted Answer   
Posted Date: September 17, 2010     Points: 10   

Hi,

Try this

SELECT Top 5 FROM Tablename ORDER By NEWID()

Author: Santosh             
Posted Date: September 17, 2010     Points: 5   

hi

SELECT * FROM IS_DAILYPLANNING ORDER By newid ()


Regards
Santosh

Author: Rajshree             
Posted Date: September 17, 2010     Points: 5   

with the help of newid() function each time different records will be genertaed .
This is inbuilt function in sql Server


Author: Syed Shakeer Hussain             
Posted Date: September 17, 2010     Points: 5   

Hi,
Try to use the Below Query to get Random records every time


SELECT Top 5 [name], [salary]FROM [dbo].[dupemp] ORDER BY NEWID()



Author: Akhil Raj       [Moderator]      
Posted Date: September 18, 2010     Points: 5   

check the following article

http://www.petefreitag.com/item/466.cfm



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend