SQL Server Random Sort

This is a duplicate of SO# 19412. Here’s the answer I gave there:

select top 1 * from mytable order by newid()

In SQL Server 2005 and up, you can use TABLESAMPLE to get a random sample that’s repeatable:

SELECT FirstName, LastName FROM Contact TABLESAMPLE (1 ROWS) ;

Leave a Comment