In SQL Server, the TAN()
function returns the tangent of the input expression.
You provide the value as an argument when calling the function.
Syntax
The syntax goes like this:
TAN ( float_expression )
Where float_expression is an expression of type float or of a type that can be implicitly converted to float, interpreted as number of radians.
Example 1 – Basic Usage
Here’s a basic example that returns the tangent of a single value.
SELECT TAN(1) Result;
Result:
+-----------------+ | Result | |-----------------| | 1.5574077246549 | +-----------------+
And with another value.
SELECT TAN(2.3) Result;
Result:
+-------------------+ | Result | |-------------------| | -1.11921364173413 | +-------------------+
Example 2 – Negative Value
Here we switch the previous value to negative value.
SELECT TAN(-2.3) Result;
Result:
+------------------+ | Result | |------------------| | 1.11921364173413 | +------------------+
Example 3 – Expressions
You can also pass in expressions like this:
SELECT TAN(2.5 + 0.3) Result;
Result:
+--------------------+ | Result | |--------------------| | -0.355529831651176 | +--------------------+
Example 4 – Passing in a Function
In this example I pass in the T-SQL PI()
function as the argument.
SELECT PI() 'PI', TAN(PI()) 'Tangent of PI';
Result:
+------------------+-----------------------+ | PI | Tangent of PI | |------------------+-----------------------| | 3.14159265358979 | -1.22464679914735E-16 | +------------------+-----------------------+