How to Select a random row with Microsoft SQL Server

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()
  • http://amedar.pl Amedar

    Nice post. Very helpful info :) Thank you.

  • Sanjay Kumar

    What a Idea Sir jiiiii

    • http://www.niteshluharuka.com Nitesh

      Sanjoy – :)