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.
| Author |
Topic |
|
indieman
Starting Member
12 Posts |
Posted - 2006-04-13 : 18:56:41
|
| i have some test data that i need to insert into a table. there needs to be about a 1000 rows so obviously i dont want to manually do it.what i need to randomise is the value of one field.. Consultant_AbilityI already have 1000 rows that have the ConsultantID number, i just need to make the Consultant_Ability random.at the moment i haveConsultantID...Consultant_Ability1..............12..............13..............14..............15..............1can anyone help me create a statement that will go through all the ConsultantID numbers and randomise the Consultant_Ability between values 0 and 10?many thanks,benedit: needs to be an update state as i have other data in there too! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-04-13 : 19:16:34
|
[code]update yourtable set Consultant_Ability = convert(int, convert(int, convert(varbinary(1), newid())) / 255.0 * 10)[/code] KH |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-04-13 : 19:57:24
|
| [code]update MyTableset Consultant_Ability = abs(convert(int,convert(varbinary(4),newid())))%11[/code]CODO ERGO SUM |
 |
|
|
indieman
Starting Member
12 Posts |
Posted - 2006-04-13 : 20:31:26
|
| thanks for the "fast as ever" responses.went with the one from khtan.thanks guys |
 |
|
|
|
|
|