четвъртък, 20 септември 2007 г.

MSSQL 2000 Query results in random order

I have a web application displaying jokes. One of the functionalities it supports is showing a random joke.
I need the get the MSSQL server to randomize the jokes for me.

Here is my very simple solution:

SELECT *
FROM joke
ORDER BY NEWID()

Each execution generates different random results.

Няма коментари: