# 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:

```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 [SQLTangent]

-- Calculating TAN directly
SELECT TAN(0.24)AS [SQLTangent]

-- Calculating TAN directly
SELECT TAN(0)AS [SQLTangent]

-- Calculating TAN directly
SELECT TAN(1)AS [SQLTangent]
```

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

`SELECT TAN(@i)AS [SQLTangent]`

## SQL 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]
,TAN ([Service Grade]) AS [TAN Function]
FROM [Mathemetical Functions]```

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.

Back to Categories SQL