Generating Random Numbers with NewID() instead of RAND()

The following fragment only computes rand() once.

Update MYTABLE set Data=RAND()

Instead, use the following: (It returns a value between 0 and 1.0)

abs(cast(cast(newid() as binary(4)) as int))/ 2147483648

About this entry