Posted by: lluppes | June 17, 2009

SQL Really Random Numbers

Ever try to get a random number in SQL, and then when you run your tests, the “random” number has these repetitive pattern?

For a really random number between 1 and 100, try this SQL:

Select RAND(Checksum(Newid())), Cast(100 * RAND(Checksum(Newid())) + 1 AS INT) AS Rnd



Advertisements

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: