SQL Server RAND() Function
Example
Return a random decimal number (no seed value - so it returns a completely random number >= 0 and <1):
SELECT RAND();
Try it Yourself »
Definition and Usage
The RAND() function returns a random number or a random number within a range.
The RAND() function will return a value between 0 (inclusive) and 1 (exclusive).
The RAND() function will return a completely random number if no seed is provided, and a repeatable sequence of random numbers if a seed value is used.
Syntax
RAND(seed)
Parameter Values
Parameter | Description |
---|---|
seed | Optional. If specified, it produces a repeatable sequence of random numbers each time that seed value is provided |
Technical Details
Works in: | SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005 |
---|