While we all know how to display a result in random order via newid() function, I wonder how the query engine interprets a GUID(result of newid), since ORDER BY statement expects a column list (or position)?
NOTE: And if the GUID somehow magically is converted to column position, this assumption is invalid for a table with single column, since it will return results in random order.
asked Nov 19 '09 at 09:41 AM in Default
As you can see in the text from books online (bold text), order by expression can include an expression. NEWID() that is nondetermanistic is executed for every row returned by your select and then order by is applied on your set of data,
answered Nov 19 '09 at 09:56 AM