When called multiple times in a single batch, rand() returns the same number.
So it is better to use convert(varbinary
,newid()
) as the seed argument:
SELECT 1.0 + floor(110 * RAND(convert(varbinary, newid()))) AS random_number
newid()
is guaranteed to return a different value each time it’s called, even within the same batch, so using it as a seed will prompt rand() to give a different value each time.
Edited to get a random whole number from 1 to 110.