Imagine you have a Product table, where you need to get a list of say 5 random products. This is how you can do it:
select top 5 *
from Product
order by newid();
So what actually happens is that newid() returns a new GUID/unique identifier for every row in the result set, it then sorts based on the GUID value and then eventually selects the 5 top most rows.

April 21st, 2008 at 9:26 pm
cool…this is new to me