Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

How to achieve Randomness in Result set

$
0
0

I want the randmonness in the result set. I am able to get it through newid() function but its expensive.The RAND() function doesn't achieve the randomness I want and it seems to be executed once per query not once per row.

Whats best alternative to achieve randmonness in the result set?.

SELECT ID FROM dbo.Test order by newid() ;

SELECT ID FROM dbo.Test order by CHECKSUM(newid()) ; SELECT ID FROM dbo.Test order by rand() ;



I90Runner




Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>