Quantcast
Channel: Select n random rows from SQL Server table - Stack Overflow
Viewing all articles
Browse latest Browse all 20

Answer by Nanki for Select n random rows from SQL Server table

$
0
0

This is a combination of the initial seed idea and a checksum, which looks to me to give properly random results without the cost of NEWID():

SELECT TOP [number] FROM table_nameORDER BY RAND(CHECKSUM(*) * RAND())

Viewing all articles
Browse latest Browse all 20

Trending Articles



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