Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Random Number

Author  Topic 

totallyNew
Starting Member

2 Posts

Posted - 2005-10-08 : 14:54:46
I need to update an integer column in my table with a random number. Here's what I've done so far (with the table name and column names changed):

UPDATE dbo.MyTable
SET Column1 = RAND() * 1000000

My question is, how come the values in my column all have the same value? I thought the RAND function gives out a random number? How can I update my table to generate random numbers?

Thanks in advance.

rfrancisco
Yak Posting Veteran

95 Posts

Posted - 2005-10-08 : 15:52:43
You may want to read into the following link:

http://www.sql-server-helper.com/tips/generate-random-numbers.aspx

Hope this helps.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-10 : 01:32:03
Refer this also
http://weblogs.sqlteam.com/jeffs/archive/2004/11/22/2927.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

totallyNew
Starting Member

2 Posts

Posted - 2005-10-10 : 23:44:16
Thanks for the links. They were both helpful.
Go to Top of Page
   

- Advertisement -