sql server - Creating test data for calculation using RAND() -
i attempted populate table 2 columns of random float
s, of every row generated identical.
;with cte (x, y) ( select rand(), rand() union select x, y cte ) --insert calculationtestdata (x, y) select top 5000000 x, y cte option (maxrecursion 0)
i can accomplish need fine not using cte
, has peaked curiosity.
is there way quickly?
i know relative term, it, mean approximately how take execute above.
what expect other cte repeat rows because you're recursion selecting them again
select rand(), rand() -- select 9 , 10 union select x, y -- select 9 , 10
what want more this
select rand(), rand() union select rand(), rand() -- problem 'row' duplicated
so need seed , reseed each row giving like
select rand(cast(newid() varbinary)), rand(cast(newid() varbinary)) union select rand(cast(newid() varbinary)), rand(cast(newid() varbinary))
using newid()
seed 1 way there may others more efficient etc
Comments
Post a Comment