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
You’re currently reading “ Generating Random Numbers with NewID() instead of RAND() ,” an entry on Chui's Counterpoint
- Published:
- 9.3.10 / 9am
- Category:
- General
Comments are closed
Comments are currently closed on this entry.