ATAN() Examples in SQL Server

In SQL Server, the ATAN() function returns the arctangent of a value. In other words, it returns the angle, in radians, whose tangent is a specified float expression.

You provide the value as an argument when calling the function.

Syntax

The syntax goes like this:

ATAN ( float_expression ) 

Where float_expression is an expression of either type float or of a type that implicitly converts to float.

Example 1 – Basic Usage

Here’s a basic example that returns the arc tangent of a single value.

SELECT ATAN(2) Result;

Result:

+------------------+
| Result           |
|------------------|
| 1.10714871779409 |
+------------------+

And with another value.

SELECT ATAN(1.3) Result;

Result:

+------------------+
| Result           |
|------------------|
| 0.91510070055336 |
+------------------+

Example 2 – Negative Value

And with a negative value.

SELECT ATAN(-1.3) Result;

Result:

+-------------------+
| Result            |
|-------------------|
| -0.91510070055336 |
+-------------------+

Example 3 – Expressions

You can also pass in expressions like this:

SELECT ATAN(2.5 + 0.3) Result;

Result:

+------------------+
| Result           |
|------------------|
| 1.22777238637419 |
+------------------+

Example 4 – Passing in a Function

In this example I pass in the T-SQL PI() function as the argument.

SELECT 
  PI() 'PI',
  ATAN(PI()) 'Arctangent of PI';

Result:

+------------------+--------------------+
| PI               | Arctangent of PI   |
|------------------+--------------------|
| 3.14159265358979 | 1.26262725567891   |
+------------------+--------------------+