--- title: "POWER (Transact-SQL)" description: "POWER (Transact-SQL)" author: MikeRayMSFT ms.author: mikeray ms.reviewer: "" ms.date: "03/13/2017" ms.prod: sql ms.prod_service: "database-engine, sql-database, synapse-analytics, pdw" ms.technology: t-sql ms.topic: reference ms.custom: "" f1_keywords: - "POWER_TSQL" - "POWER" helpviewer_keywords: - "POWER function" dev_langs: - "TSQL" monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current" --- # POWER (Transact-SQL) [!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)] Returns the value of the specified expression to the specified power. ![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 POWER ( float_expression , y ) ``` [!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)] ## Arguments *float_expression* Is an [expression](../../t-sql/language-elements/expressions-transact-sql.md) of type **float** or of a type that can be implicitly converted to **float**. *y* Is the power to which to raise *float_expression*. *y* can be an expression of the exact numeric or approximate numeric data type category, except for the **bit** data type. ## Return Types The return type depends on the input type of *float_expression*: |Input type|Return type| |----------|-----------| |**float**, **real**|**float**| |**decimal(*p*, *s*)**|**decimal(38, *s*)**| |**int**, **smallint**, **tinyint**|**int**| |**bigint**|**bigint**| |**money**, **smallmoney**|**money**| |**bit**, **char**, **nchar**, **varchar**, **nvarchar**|**float**| If the result does not fit in the return type, an arithmetic overflow error occurs. ## Examples ### A. Using POWER to return the cube of a number The following example demonstrates raising a number to the power of 3 (the cube of the number). ```sql DECLARE @input1 FLOAT; DECLARE @input2 FLOAT; SET @input1= 2; SET @input2 = 2.5; SELECT POWER(@input1, 3) AS Result1, POWER(@input2, 3) AS Result2; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` Result1 Result2 ---------------------- ---------------------- 8 15.625 (1 row(s) affected) ``` ### B. Using POWER to show results of data type conversion The following example shows how the *float_expression* preserves the data type which can return unexpected results. ```sql SELECT POWER(CAST(2.0 AS FLOAT), -100.0) AS FloatResult, POWER(2, -100.0) AS IntegerResult, POWER(CAST(2.0 AS INT), -100.0) AS IntegerResult, POWER(2.0, -100.0) AS Decimal1Result, POWER(2.00, -100.0) AS Decimal2Result, POWER(CAST(2.0 AS DECIMAL(5,2)), -100.0) AS Decimal2Result; GO ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` FloatResult IntegerResult IntegerResult Decimal1Result Decimal2Result Decimal2Result ---------------------- ------------- ------------- -------------- -------------- -------------- 7.88860905221012E-31 0 0 0.0 0.00 0.00 ``` ### C. Using POWER The following example returns `POWER` results for `2`. ```sql DECLARE @value INT, @counter INT; SET @value = 2; SET @counter = 1; WHILE @counter < 5 BEGIN SELECT POWER(@value, @counter) SET NOCOUNT ON SET @counter = @counter + 1 SET NOCOUNT OFF END; GO ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` ----------- 2 (1 row(s) affected) ----------- 4 (1 row(s) affected) ----------- 8 (1 row(s) affected) ----------- 16 (1 row(s) affected) ``` ## Examples: [!INCLUDE[ssSDWfull](../../includes/sssdwfull-md.md)] and [!INCLUDE[ssPDW](../../includes/sspdw-md.md)] ### D: Using POWER to return the cube of a number The following example shows returns `POWER` results for `2.0` to the 3rd power. ```sql SELECT POWER(2.0, 3); ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ``` ------------ 8.0 ``` ## See Also [decimal and numeric (Transact-SQL)](../../t-sql/data-types/decimal-and-numeric-transact-sql.md) [float and real (Transact-SQL)](../../t-sql/data-types/float-and-real-transact-sql.md) [int, bigint, smallint, and tinyint (Transact-SQL)](../../t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql.md) [Mathematical Functions (Transact-SQL)](../../t-sql/functions/mathematical-functions-transact-sql.md) [money and smallmoney (Transact-SQL)](../../t-sql/data-types/money-and-smallmoney-transact-sql.md)