Tuesday, June 26, 2007

[sql] Generate Random Numbers

Good trick (and very nicely put together article) that Mike found http://www.sql-server-helper.com/tips/generate-random-numbers.aspx

SELECT ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT))

Double casts with absolute value. Awesome.

No comments:

Post a Comment