Selecting random records in SQL Server

Sunday, 17 May 2009

Here's a way to select the random records from a table


select top 5 name 
from sys.objects
order by newid()

This query will return 5 random tables from sys.objects each time you execute it.

Know more about newid() here

0 comments: