Sunday, July 24, 2011

Random result in MS SQL

To get Random result form a MS SQL table you can user newid(). This will give you random order of rows each time you run the SQL statement.

    TOP 10 *   
    [Where Condition]
Order by NEWID()

This will give you the Random Rows from you table.

No comments:

Post a Comment