SQL TAN Function

The SQL TAN function is a Mathematical Function that calculates the trigonometry Tangent for the specified expression. The syntax of the SQL Server TAN Function is:

-- SQL Server TAN Syntax
SELECT TAN (Float_Expression)
FROM [Source]

SQL TAN Function Example 1

The mathematical formula for this function is TAN(x) = Length of the Opposite Side / Length of the Adjacent Side. The TAN Function calculates the Tangent value for the given angle. The following SQL Server query shows multiple ways to use the Tangent function.

DECLARE @i float
SET @i = 208.45

SELECT TAN(@i)AS [SQL Tangent]

-- Calculating TAN directly
SELECT TAN(0.24)AS [SQL Tangent]

-- Calculating TAN directly
SELECT TAN(0)AS [SQL Tangent]

-- Calculating TAN directly
SELECT TAN(1)AS [SQL Tangent]
SQL TAN FUNCTION 1

We used the TAN Mathematical Function to calculate the Tangent value for the variable @i. It means TAN(208.45))

SELECT TAN(@i)AS [SQL Tangent]

TAN Function Example 2

We are going to calculate the Tangent value for all the records present in [Tax Amount] and [Service Grade] using TAN Function.

For this TAN Function demo, we use the Math Table data

SELECT [EnglishProductName]
      ,[SalesAmount]
      ,[TaxAmt]
      ,TAN([TaxAmt]) AS [Tax Tangent]
      ,[Service Grade] AS Grade
      ,TAN ([Service Grade]) AS [TAN Function] 
  FROM [Mathemetical Functions]
SQL TAN FUNCTION 2