SQL Server Tutorial SQL Server Advanced SQL Server Database SQL Server References

SQL Server - COT() Function



The SQL Server (Transact-SQL) COT() function returns trigonometric cotangent of an angle (angle should be in radians). In special cases it returns the following:

  • If x is 0, then an error is returned.

Syntax

COT(x)

Parameters

x Required. Specify the angle in radian.

Return Value

Returns the trigonometric cotangent of an angle.

Example 1:

The example below shows the usage of COT() function.

SELECT COT(1);
Result: 0.64209261593433065

SELECT COT(2);
Result: -0.45765755436028577

SELECT COT(3);
Result: -7.0152525514345339

SELECT COT(-1);
Result: -0.64209261593433065

SELECT COT(-2);
Result: 0.45765755436028577

SELECT COT(-3);
Result: 7.0152525514345339

SELECT COT(PI());
Result: -8165619676597685.0

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 10.5
Data 21
Data 35
Data 410
Data 550

The query given below can be used to calculate the trigonometric cotangent value of column x.

SELECT *, COT(x) AS COT_Value FROM Sample;

This will produce the result as shown below:

DataxCOT_Value
Data 10.51.830487721712452
Data 210.64209261593433065
Data 35-0.29581291553274552
Data 4101.54235104535692
Data 550-3.6778144508505695

❮ SQL Server Functions

5