Friday, September 29, 2006

Query Select random row

I was looking for a way to select a random row from a table, preferably in a stored procedure.
This is the query:

SELECT TOP (1) *
FROM table
ORDER BY NEWID()

Simple and effective!

No comments: