--- description: "RAND (Transact-SQL)" title: "RAND (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/06/2017" ms.prod: sql ms.prod_service: "sql-data-warehouse, database-engine, sql-database" ms.reviewer: "" ms.technology: t-sql ms.topic: reference f1_keywords: - "RAND" - "RAND_TSQL" dev_langs: - "TSQL" helpviewer_keywords: - "RAND function" - "values [SQL Server], random float" - "random float value" ms.assetid: 363c84d6-b9fa-49ba-9a75-e44f27535ff6 author: julieMSFT ms.author: jrasnick monikerRange: "=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current" --- # RAND (Transact-SQL) [!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa.md)] Returns a pseudo-random **float** value from 0 through 1, exclusive. ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ```syntaxsql RAND ( [ seed ] ) ``` [!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)] [!INCLUDE[synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)] ## Arguments *seed* Is an integer [expression](../../t-sql/language-elements/expressions-transact-sql.md) (**tinyint**, **smallint**, or **int**) that gives the seed value. If *seed* is not specified, the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)] assigns a seed value at random. For a specified seed value, the result returned is always the same. ## Return Types **float** ## Remarks Repetitive calls of RAND() with the same seed value return the same results. For one connection, if RAND() is called with a specified seed value, all subsequent calls of RAND() produce results based on the seeded RAND() call. For example, the following query will always return the same sequence of numbers. ```sql SELECT RAND(100), RAND(), RAND() ``` ## Examples The following example produces four different random numbers that are generated by the RAND function. ```sql DECLARE @counter SMALLINT; SET @counter = 1; WHILE @counter < 5 BEGIN SELECT RAND() Random_Number SET @counter = @counter + 1 END; GO ``` ## See Also [Mathematical Functions (Transact-SQL)](../../t-sql/functions/mathematical-functions-transact-sql.md)