Oct 19, 2007

SQL- Randomizing select records

the newid() function creates a unique value of type uniqueidentifier.


For example:
SELECT newid()

returns:
031FF281-A80A-4836-B2B4-81F9A6D0536E

We can use this function to randomly sort records, It's simple:

SELECT * FROM tbl_name

ORDER BY newid()

Have fun.

No comments: