Home > T-SQL > Trigonometric Functions SIN, COS, TAN in SQL Server – Math Functions @SQLSERVER

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:

  1. sin(angle)        –  It returns sine of the specified angle in radians float value
  2. asine(sine)       – It returns the angle of the sine value in radians float value.
  3. cos(angle)        – It returns the cosine of the specified angle in radians float value.
  4. acos(cos)          – It returns the angle of the cosine in radians float value.
  5. cot(angle)         – It returns the cotangent of the specified angle in radians float value.
  6. tan(angle)        – It returns the tangent of the given angle and it returns a float value.
  7. atan(tangent)  – It returns the angle in radians of the given tangent float value.
  8. 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

pic1SQL Script:

set nocount on
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.

Advertisements
  1. December 27, 2013 at 12:18 pm

    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).

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: