September 12, 2012 by Nitesh

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()
#SQL Server#Utilities

Support us!

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

Powered by WordPress Popup