rand

Description

Returns a random float value between 0 and 1 using the specified (optional) integer as a 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

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute rand.

See also

Datatypes Approximate numeric datatypes

Documentation Transact-SQL Users Guide

Functions rand2