I need a different random number for each row in my table. The following seemingly obvious code uses the same random value for each row.
SELECT table_name,
It's as easy as:
DECLARE @rv FLOAT; SELECT @rv = rand();
And this will put a random number between 0-99 into a table:
CREATE TABLE R ( Number int ) DECLARE @rv FLOAT; SELECT @rv = rand(); INSERT INTO dbo.R (Number) values((@rv * 100)); SELECT * FROM R