Logo

RANDBETWEEN

Updated 2023-10-18 15:30:32.843000

Syntax

SELECT [westclintech].[wct].[RANDBETWEEN] (
   <@Bottom, float,>
 ,<@Top, float,>)

Description

Use the scalar function RANDBETWEEN to calculate a random integer number between the numbers you specify.

Arguments

@Top

is the largest integer that could be returned. @Top is an expression of type float or of a type that can be implicitly converted to float.

@Bottom

is the smallest integer that could be returned. @Bottom is an expression of type float or of a type that can be implicitly converted to float.

Return Type

float

Remarks

@Top and @Bottom will be truncated to integers.

RANDBETWEEN is non-deterministic, so results will vary.

Examples

SELECT wct.RANDBETWEEN(-100, 100);

Here is the result set.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"-46"}]}