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
 insert random values in a table

Author  Topic 

landau66
Yak Posting Veteran

61 Posts

Posted - 2007-12-14 : 05:45:17
Hi all!

I want to fill a table with random values. In each line should be a different value - "independet" from the value the row above.

what i tried didnt work, it always produced the same value.



Maybe you have an idea

Thankx in advance and greetings from Vienna

Landau

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-14 : 05:47:38
http://sqlserver-tips.blogspot.com/2006/09/populating-column-with-random-values.html

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-14 : 06:17:14
Also try

update table set col = (select abs(cast(cast(newid() as varbinary(100)) as int)))

Some more methods
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/10/10/generating-random-numbers-part-ii.aspx

Madhivanan

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

- Advertisement -