Calculate and return the natural logarithm of 2.
SELECT LOG(2); |
The LOG() function computes the natural logarithm of a given number or can compute the logarithm of a number to a specified base.
Starting from SQL Server 2012, you can adjust the base of the logarithm using an optional parameter.
Note: Consider exploring the EXP() function for exponential calculations.
LOG(number, base) — Syntax for SQL Server |
OR:
LOG(number) — Syntax for Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse |
Parameter |
Description |
number |
Required: The input number for which the natural logarithm is calculated, must be greater than 0. |
base |
Optional: The base with which the natural logarithm is computed, must be greater than 1. |
Works in: |
SQL Server (beginning from 2008), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse |
Calculate and return the natural logarithm of 2 with a specified base of 4.
SELECT LOG(2, 4); |