## Trigonometric Functions SIN, COS, TAN in SQL Server – Math Functions @SQLSERVER

Trigonometric or circular functions are functions of an angle. They are used to relate the angles of a triangle to the lengths of the sides of a triangle. – Wikipedia

These function are playing a vital role in navigation, engineering and physics. We have these functions in SQL Server. So, it is simple to do the trigonometric calculation in the database.

Learn about Degrees and Radians functions here

SQL Server Trigonometric Functions:

- sin(angle) – It returns sine of the specified angle in radians float value
- asine(sine) – It returns the angle of the sine value in radians float value.
- cos(angle) – It returns the cosine of the specified angle in radians float value.
- acos(cos) – It returns the angle of the cosine in radians float value.
- cot(angle) – It returns the cotangent of the specified angle in radians float value.
- tan(angle) – It returns the tangent of the given angle and it returns a float value.
- atan(tangent) – It returns the angle in radians of the given tangent float value.
- atn2(x,y) – It returns the angle in radians between the positive x-axis and the ray from the origin to the point (y, x). Here x and y are float values.

**Implementation**

select Sin(45) as ‘SIN’

select asin(Sin(45)) ‘ASIN’select cos(30) as ‘COS’

select acos(cos(30)) as ‘ACOS’

select cot(30) as ‘COT’select tan(120) as ‘TAN’

select atan(tan(120)) as ‘ATAN’

select atn2(1.5, 2) as ‘ATN2’

We have learned trigonometric functions in SQL Server. So, make use of these functions in your application at data access layer.

Categories: T-SQL
#SQLSERVER, acos, asin, atan, atn2, cos, cot, sin, SQL Server, SQLRider, sqlserverrider, tan

It is a little bit disingenuous to use angles of 30 and 45 radians in the example, since this may lead people to believe the angle is given in degrees (although closer reading shows that this is not the case – you explicitly state “radians” several times). It would be better to use values that are more obviously radians (3.14159 / 4 for example).