POWER (Transact-SQL)
This page is specific to: Version:
SQL Server 2005
SQL Server 2005 Books Online (November 2008)
POWER (Transact-SQL)

Updated: 14 April 2006

Returns the value of the specified expression to the specified power.

Topic link icon Transact-SQL Syntax Conventions

Syntax

POWER ( float_expression , y )
Arguments

float_expression

Is an expression 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

Same as float_expression.

Examples

A. Using POWER to show results of 0.0

The following example shows a floating point underflow that returns a result of 0.0.

SELECT POWER(2.0, -100.0)
GO

Here is the result set.

------------------------------------------
0.0

(1 row(s) affected)

B. Using POWER

The following example returns POWER results for 2.

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

Here is the result set.

----------- 
2           

(1 row(s) affected)

----------- 
4           

(1 row(s) affected)

----------- 
8           

(1 row(s) affected)

----------- 
16          

(1 row(s) affected)
See Also

Reference

decimal and numeric (Transact-SQL)
float and real (Transact-SQL)
int, bigint, smallint, and tinyint (Transact-SQL)
Mathematical Functions (Transact-SQL)
money and smallmoney (Transact-SQL)

Other Resources

Using the POWER and EXP Exponential Functions

Help and Information

Getting SQL Server 2005 Assistance
Change History

Release History

14 April 2006

Changed content:
  • Changed numeric_expression argument to float_expression in the syntax and the related argument description.
© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View