The SQL Server ATN2 function is a Mathematical Function that returns the angle between the positive x-axis and the line from the origin to the point (y, x). The syntax of the ATN2 Function is.
SELECT ATN2 (Float_Expression, Float_Expression) FROM [Source]
For this ATN2 Function demo, we use the below data

SQL ATN2 Function Example
The ATN2 function finds the angle between the positive x-axis and the line from the origin to the point (y, x). Here, the x and y values are the two arguments we are going to provide for the ATN2 function. The following Mathematical Function query shows multiple ways to use this one. Please refer to the list of SQL Math functions from our SQL Server tutorial page.
DECLARE @i Float = 50.05, @j Float = 200.05 SELECT ATN2(@i, @j) AS [ATN2 Function] SELECT ATN2(100.27, 50.27) AS [ATN2 Function] SELECT ATN2(22.45 + 77.55, 100) AS [ATN2 Function]

In the following SELECT statement, we used the ATN2 function to find the angle between @i and @j and assigned a new name, ‘ATN2 Function’, using ALIAS.
SELECT ATN2(@i, @j) AS [ATN2 Function]
In this SQL SELECT statement example, we will calculate the angle between the values present in [Standard Cost] and [Sales Amount]. Please refer to the SQL COT and SQL ATAN functions from the list of Mathematical Functions.
SELECT [EnglishProductName]
,[Color]
,[StandardCost]
,[SalesAmount]
,ATN2([StandardCost], [SalesAmount]) AS [ATN2 Function]
FROM [Mathemetical Functions]
