How to get a random row from a table

select top 1 columns....
from table
order by newid()

-- choosing between first 20 rows
set ROWCOUNT 20
select top 1 *
from (Select * from table)
order by newid()
set ROWCOUNT 0

Source: https://weblogs.sqlteam.com/mladenp/2005/08/01/7421/
Viewed 17242 times