rand

Description

Returns a random value between 0 and 1, which is generated using the specified seed value.

Syntax

rand([integer])

Parameters

integer

is any integer (tinyint, smallint or int) column name, variable, constant expression, or a combination of these.

Examples

Example 1

select rand()

--------------------
           0.395740

Example 2

declare @seed int
select @seed=100
select rand(@seed)

-------------------- 
             0.000783 

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute rand.

See also

Datatypes Approximate numeric datatypes