Logo

SQL Server POWER Function

Updated 2023-10-13 20:39:52.133000

Description

Use the scalar function POWER to return the value of the specified expression to the specified power.

Syntax

SELECT [westclintech].[wct].[POWER] (
   <@x, float,>
  ,<@y, float,>)

Arguments

@x

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 @x. @y is an expression of type float or of a type that can be implicitly converted to float.

Return Type

float

Remarks

If POWER evaluates to > 1.79769313486232E+308 then NULL is returned.

If @x < 0 and @y is not an integer then NULL is returned.

Examples

SELECT x,
       y,
       wct.POWER(x, y) as [POWER]
FROM
(
    VALUES
        (2, 0),
        (2, 1023),
        (2, 1024),
        (2, -1075),
        (-2, -1075),
        (-2, 3.5),
        (0, 0)
) n (x, y);

This produces the following result.

xyPOWER
20.01
21023.08.98846567431158E+307
21024.0NULL
2-1075.04.94065645841247E-324
-2-1075.0-4.94065645841247E-324
-23.5NULL
00.01