返回 0 到1 之間的隨機float 值。
RAND ( [ seed ] )
seed
是給出種子值或起始值的整型表達(dá)式(tinyint、smallint 或 int)。
float
在單個查詢中反復(fù)調(diào)用 RAND() 將產(chǎn)生相同的值。
下例產(chǎn)生 4 個通過 RAND 函數(shù)產(chǎn)生的不同的隨機值。
DECLARE @counter smallint
SET @counter = 1
WHILE @counter < 5
BEGIN
SELECT RAND(@counter) Random_Number
SET NOCOUNT ON
SET @counter = @counter + 1
SET NOCOUNT OFF
END
GO
下面是結(jié)果集:
Random_Number
-------------------
0.71359199321292355
(1 row(s) affected)
Random_Number
-------------------
0.7136106261841817
(1 row(s) affected)
Random_Number
-------------------
0.71362925915543995
(1 row(s) affected)
Random_Number
-------------------
0.7136478921266981
(1 row(s) affected)
相關(guān)文章