ATN2() Function in SQL Server
The ATN2() function in SQL Server returns the arctangent of two specified float expressions. It takes two arguments, x and y, and returns the angle whose tangent is the quotient of the two specified expressions.
Syntax:
ATN2 ( y , x )
Arguments: - y: A float expression. - x: A float expression.
Return Type: - Returns a float value.
Example 1:
SELECT ATN2(2, 1) AS Result;
Output:
Result
1.10714871779409
Example 2:
DECLARE @x FLOAT = 2;
DECLARE @y FLOAT = 1;
SELECT ATN2(@y, @x) AS Result;
Output:
Result
1.10714871779409
Note: The ATN2() function is similar to the ATAN() function, but it takes two arguments instead of one. The ATN2() function returns a value between -π and π radians (-180 and 180 degrees), whereas the ATAN() function returns a value between -π/2 and π/2 radians (-90 and 90 degrees).