rand2

Description

Returns a random value between 0 and 1, which is generated using the specified seed value, and computed for each returned row when used in the select list.

Syntax

rand ([integer])

Parameter

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

Example

Example 1

If there are n rows in table t, the following select statement returns n different random values.

select rand2 from t
------------

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute rand2.

See also

Datatypes Approximate numeric datatypes.