COT() Examples in SQL Server

In SQL Server, the T-SQL COT() function is a mathematical function that returns the trigonometric cotangent of the specified angle – in radians – in the specified float expression.

You specify the angle by providing an argument to the function when calling it.

Syntax

The syntax goes like this:

COT ( float_expression )  

Where float_expression is an expression of type float, or of a type that can implicitly convert to float.

Example 1 – Basic Usage

Here’s an example to demonstrate.

SELECT COT(1) Result;

Result:

+-------------------+
| Result            |
|-------------------|
| 0.642092615934331 |
+-------------------+

And with a different value:

SELECT COT(2) Result;

Result:

+--------------------+
| Result             |
|--------------------|
| -0.457657554360286 |
+--------------------+

Example 2 – Fractions

The argument can have a fractional component.

SELECT COT(1.52) Result;

Result:

+--------------------+
| Result             |
|--------------------|
| 0.0508400612929196 |
+--------------------+

Example 3 – Expressions

You can also use expressions like this:

SELECT COT(1 + 2) Result;

Result:

+-------------------+
| Result            |
|-------------------|
| -7.01525255143453 |
+-------------------+

So that’s the same as doing this:

SELECT COT(3) Result;

Result:

+-------------------+
| Result            |
|-------------------|
| -7.01525255143453 |
+-------------------+