Quantcast
Channel: Answers for "What algorithm does RAND() in SQL Server use?"
Browsing all 4 articles
Browse latest View live

Answer by Peso

I wouldn't use RAND. Nowadays I use ABS(CHECKSUM(NEWID())) % 1000 to get random number between 0 and 999. It has better distribution than RAND(). Also RAND() alwasys returns same value first time after...

View Article



Answer by paganaye

Here is my attempt to guessing the Algorithm used in SQL Rand() This algorithm returns the same value than SQL on my machine. Let me know if this works with you. This is C# code. public class SQLRand {...

View Article

Answer by Peso

I wouldn't use RAND. Nowadays I use ABS(CHECKSUM(NEWID())) % 1000 to get random number between 0 and 999. It has better distribution than RAND(). Also RAND() alwasys returns same value first time after...

View Article

Answer by paganaye

Here is my attempt to guessing the Algorithm used in SQL Rand() This algorithm returns the same value than SQL on my machine. Let me know if this works with you. This is C# code. public class SQLRand {...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images