Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Returns the natural logarithm of the specified float expression in SQL Server.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database, Azure SQL Data Warehouse Public Preview.
By default, LOG() returns the natural logarithm. Starting with SQL Server 2012, you can change the base of the logarithm to another value by using the optional base parameter.
The natural logarithm is the logarithm to the base e, where e is an irrational constant approximately equal to 2.718281828.
The natural logarithm of the exponential of a number is the number itself: LOG( EXP( n ) ) = n. And the exponential of the natural logarithm of a number is the number itself: EXP( LOG( n ) ) = n.
A. Calculating the logarithm for a number.
The following example calculates the LOG for the specified float expression.
DECLARE @var float = 10; SELECT 'The LOG of the variable is: ' + CONVERT(varchar, LOG(@var)); GO
Here is the result set.
------------------------------------- The LOG of the variable is: 2.30259 (1 row(s) affected)