EXP() Function in SQL Server
The EXP() function in SQL Server is used to return the exponential value of the specified numeric expression. The exponential value is calculated as e raised to the power of the specified numeric expression.
Syntax:
EXP(numeric_expression)
Where numeric_expression
is the numeric value for which the exponential value needs to be calculated.
Example:
SELECT EXP(2) AS ExponentialValue;
Output:
ExponentialValue
----------------
7.38905609893065
In the above example, the EXP() function returns the exponential value of 2, which is approximately 7.39.
Another example:
SELECT EXP(0) AS ExponentialValue;
Output:
ExponentialValue
----------------
1
In the above example, the EXP() function returns the exponential value of 0, which is 1.
Multiple methods to calculate exponential value in SQL Server: 1. Using the POWER() function:
SELECT POWER(2.718281828, 2) AS ExponentialValue;
Output:
ExponentialValue
----------------
7.389056098
- Using the exponential operator:
SELECT 2.718281828 ** 2 AS ExponentialValue;
Output:
ExponentialValue
----------------
7.389056098