It seems that Select Rand(5)
always returns the same number - I checked on three computers. But can I assume that it will always (on any SQL Server instance) return the same number (0.713666525097956)?
And of course, if that will be the case for any other parameter of Rand()
function.
1条答案
按热度按时间kxeu7u2r1#
This is documented and expected behaviour:
Returns a pseudo-random
float
value from 0 through 1, exclusive.seed
Is an integer expression (
tinyint
,smallint
, orint
) that gives the seed value. If seed isn't specified, the SQL Server Database Engine assigns a seed value at random. For a specified seed value, the result returned is always the same.Emphasis mine.
If you want a true random number
RAND
is not your friend.