SQL LOG Function

LOG returns the natural logarithm of the specified value.

The base of the logarithm can be changed starting with SQL Server 2012.

Example

#

This example returns the natural logarithm of the specified value.

SELECT LOG(10) AS Ln
Result:  1 record
Ln
2.30258509299405

Syntax

Syntax of the LOG function.

LOG(value [,base])

value -- a value greater than 0.

base -- optional. Sets the base of the logarithm. Must be greater than 1.

More Examples

LOG with BASE

Returns the natural logarithm of a value with a base indicated.
SELECT LOG(8, 4) AS 'Log 8 base 4'
Result:  1 record
Log 8 base 4
1.5

You may also like



Guides


vsn 3.1