“LOG” function enhancement in SQL Server 2012

Introduction

Up till SQL Server 2012, the LOG function only supported the natural log. But from SQL Server 2012, the LOG function started to accept the base value (as the second parameter) as well.

Syntax

LOG(number,[base])

Number: It is the positive number for which we want the logarithm

Base: It is the base of the logarithm. Default value is 10.

Return Type: Decimal number

Example:

SELECT LOG(8)
 
--Output

-- 2.07944154167984

SELECT LOG(8,3)

--Output

-- 1.89278926071437

Next Recommended Reading Format Function in SQL Server 2012