SQL Server TAN() Function
The TAN()
function in SqlServer is used to return the tangent value of a number.
Syntax
TAN ( numeric_expression )
Where numeric_expression
is a numeric expression that represents the angle in radians.
Usage
The TAN()
function can be used for various mathematical calculations and analyses, such as computing the tangent value of an angle in trigonometry.
Examples
Example 1
Return the tangent value of an angle of 45 degrees.
SELECT TAN(RADIANS(45)) AS TanValue;
Result:
TanValue |
---|
1.000000 |
Example 2
Return the tangent values of all numeric columns in a table.
SELECT col1, TAN(col2) AS TanValue
FROM MyTable;
Result:
col1 | TanValue |
---|---|
1 | -6.799711 |
2 | 1.557408 |
3 | 0.142546 |
4 | 1.157821 |
5 | -3.380515 |
Conclusion
With the TAN()
function, SqlServer can quickly and accurately compute the tangent values of numeric expressions. The TAN()
function is a useful tool in cases where angle calculations or trigonometric functions are needed.