SQL Server Tutorial SQL Server Advanced SQL Server Database SQL Server References

SQL Server - TAN() Function



The SQL Server (Transact-SQL) TAN() function returns trigonometric tangent of an angle (angle should be in radians).

Syntax

TAN(x)

Parameters

x Required. Specify the angle in radian.

Return Value

Returns the trigonometric tangent of an angle.

Example 1:

The example below shows the usage of TAN() function.

SELECT TAN(0);
Result: 0.0

SELECT TAN(1);
Result: 1.5574077246549023

SELECT TAN(-1);
Result: -1.5574077246549023

SELECT TAN(2);
Result: -2.1850398632615189

SELECT TAN(-2);
Result: 2.1850398632615189

SELECT TAN(PI());
Result: -1.2246467991473532E-16

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 1-10
Data 2-5
Data 30
Data 45
Data 510

The query given below can be used to calculate the trigonometric tangent value of column x.

SELECT *, TAN(x) AS TAN_Value FROM Sample;

This will produce the result as shown below:

DataxTAN_Value
Data 1-10-0.64836082745908663
Data 2-53.3805150062465859
Data 300.0
Data 45-3.3805150062465859
Data 5100.64836082745908663

❮ SQL Server Functions

5