SQL Server LOG10() Function
Updated on
LOG10() returns the base-10 logarithm of a float expression as a float. The input must be a float or a type that SQL Server can implicitly convert to float. For example, LOG10(100) is 2 because 10 raised to the second power is 100. See Microsoft’s LOG10() reference.
Syntax
LOG10(float_expression)
float_expression can be a float value or an implicitly convertible numeric expression. The return type is float.
Examples
Powers of ten map to their exponents:
SELECT LOG10(10) AS log_of_10,
LOG10(100) AS log_of_100,
LOG10(1) AS log_of_1;
| log_of_10 | log_of_100 | log_of_1 |
|---|---|---|
| 1.0 | 2.0 | 0.0 |
Use LOG() when you need the natural logarithm or a different base; SQL Server 2012 (11.x) and later accept an optional base argument.