Get the Random Records from a Table

Posted by Lakhangarg under Sql Server category on | Views : 1982
Query to Get the Random Records from a Table in a Database.
Supoose we want to show 5 Random News on main page of the website.
Table Name:tblNews
Columns: NewsID,Description,DatePosted
SELECT TOP 5 NewsID,Description,DatePosted FROM tblNews ORDER By NEWID() 

OUTPUT: 5 News will be fetched from table at Random. each times 5 different news will be picked from the table.

Thanks & Regards
Lakhan Pal Garg

Comments or Responses

Login to post response