top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Work with common MATH functions in SQL server 2008?

0 votes
350 views
How to Work with common MATH functions in SQL server 2008?
posted Mar 23, 2016 by Jayshree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

COT()

COT () is one of the commonly used MATH functions available in SQL Server. It is used to find the trigonometric cotangent value of any given expression, represented in radians.

It takes only one parameter which can be of data type float or of any data type that can be explicitly converted to float data type. This function returns the result in float data type.

Syntax:

COT (float_expression)

Example:

SELECT COT (-2.5), COT (2.5)

Output:


1.33864812830415 -1.33864812830415

SIN ()

Another most commonly used function is, SIN () in SQL Server. It is used to find the trigonometric sine value of any given expression, represented in radians.

It takes only one parameter which can be of data type float or of any data type that can be explicitly converted to float data type. This function returns the result in float data type.

Syntax:

SIN (float_expression)

Example:

SELECT SIN (-2.5), SIN (2.5)

Output:


-0.598472144103956 0.598472144103956

TAN ()

TAN () is also one of the most commonly used Math functions in SQL Server. It is used to find the tangent value of any given expression, represented in radians.

It takes only one parameter which can be of data type float or of any data type that can be explicitly converted to float data type. This function returns the result in float data type.

Syntax:

TAN (float_expression)

Example:

SELECT TAN (-2.5), TAN (2.5)

Output:


0.74702229723866 -0.74702229723866

RADIANS ()

RADIANS () is another most commonly used Math function, used to find out the angle in radians when angle in degrees is given.

It takes one parameter as an input, which is the angle in degrees. The data type of input parameter can be any numeric data type except ‘bit’ data type. This function returns the result in the same data type as it receives as input parameter.

Syntax:

RADIANS (numeric_expression)

Example:

SELECT RADIANS (90), RADIANS (-90), RADIANS (0), RADIANS (45), RADIANS(62.25)

Output:


1 -1 0 0 1.086467459366470000

For every value which is quite low to compute the angle in radians, it shows result 0 (zero) for it.

DEGREES ()

DEGREES () is another most commonly used Math function in SQL Server, to find out the angle in degrees when angle in radians is given.

It takes one parameter as an input, which is the angle in radians. The data type of input parameter can be any numeric data type except ‘bit’ data type. This function returns the result in the same data type as it receives as input parameter.

Syntax:

DEGREES (numeric_expression)

Example:

SELECT DEGREES (3.214), DEGREES (-1.571), DEGREES (0)

Output:


184.148635355046590000 -90.011669615052327000 0

answer Mar 23, 2016 by Shivaranjini
...