For testing purposes I want to update a table by setting bits in colums to a random value.
update [Planned]
set [IsPlannable] = 1 * rand(cast(cast(newid() as binary(8)) as int))
WHERE [ComputerID] > 100
It does seem to work as it should but not the way I want it. I guess the problem is the result will most of the time be higher than 1.
How can I flip random bits to random values?
The
1 *is still yielding a fractional number & given thatcast(0.1 as bit)will yeild 1 as willcast(0.9 as bit)the updates are all set to 1.You could;