How to Select a random row with Microsoft SQL Server

September 12th, 2012 | Posted by Nitesh Luharuka in General | SQL Server | Utility

A quick post for all –

We often find situations where we need to retrieve random records from a MS SQL table. The below query does the same for you.

To generate a random record from a table in Microsoft SQL Server, we need to execute the following query:

SELECT TOP 1 * FROM tbl_name ORDER BY NEWID()

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

  • http://amedar.pl Amedar

    Nice post. Very helpful info :) Thank you.

  • Sanjay Kumar

    What a Idea Sir jiiiii

    • http://www.niteshluharuka.com Nitesh

      Sanjoy – :)

Support us!

If you like this site please help and make click on any of these buttons!

×