RAND (T-SQL) Returns a random float value between 0 and 1.Syntax RAND([seed])Arguments seed Is an integer expression (tinyint, smallint, or int) giving the seed or starting value. Return Types floatExamples This example uses a variable to produce five different random numbers generated with the RAND function.DECLARE @counter smallintSET @counter = 1WHILE @counter < 5 BEGIN SELECT RAND(@counter) SET NOCOUNT ON SET @counter = @counter + 1 SET NOCOUNT OFF ENDGO Here is the result set:(1 row(s) affected) ------------------------ 0.00125125888851588 (1 row(s) affected) ------------------------ 0.00137333292641987 (1 row(s) affected) ------------------------ 0.00146488845484787 (1 row(s) affected) ------------------------ 0.00155644398327586 (1 row(s) affected)
Returns a random float value between 0 and 1.Syntax
RAND([seed])Arguments
seed
Is an integer expression (tinyint, smallint, or int) giving the seed or starting value.
Return Types
floatExamples
This example uses a variable to produce five different random numbers generated with the RAND function.DECLARE @counter smallintSET @counter = 1WHILE @counter < 5 BEGIN SELECT RAND(@counter) SET NOCOUNT ON SET @counter = @counter + 1 SET NOCOUNT OFF ENDGO Here is the result set:(1 row(s) affected) ------------------------ 0.00125125888851588 (1 row(s) affected) ------------------------ 0.00137333292641987 (1 row(s) affected) ------------------------ 0.00146488845484787 (1 row(s) affected) ------------------------ 0.00155644398327586 (1 row(s) affected)