The SQL ATAN function is one of the Mathematical Function which is used to calculate the trigonometry Arc tangent for the specified expression. Arc tangent is also called as inverse of a Tangent, Please refer SQL TAN Function article to understand the Tangent Function.
SQL ATAN Function Syntax
The basic syntax of the ATAN Function in SQL Server is as shown below:
SELECT ATAN (Float_Expression) FROM [Source]
In this article we will show you, How to write ATAN Function in SQL Server with example. For this, We are going to use the below shown data
SQL ATAN Function Example 1
The ATAN Function is used to calculate the Arctangent value for the given angle. The following query will show multiple ways to use ATAN function.
DECLARE @i Float SET @i = -208.80 SELECT ATAN(@i) AS [Arc Tangent] -- Calculating ATAN directly SELECT ATAN(0.27) AS [Arc Tangent] -- Calculating ATAN directly SELECT ATAN(22.25 + 78.55 - 140.77) AS [Arc Tangent]
Below lines of code is used to declare float variable and assigning the value.
DECLARE @i float SET @i = -208.80
In the below statement, We used ATAN function to calculate the Arc Tangent value for the variable @i (It means ATAN(-208.80)). We also assigned new name to that result as ‘Arc Tangent’ using ALIAS Column.
SELECT TAN(@i) AS [SQL Tangent]
In the next statements, We used the ATAN Function directly on the float values.
SQL ATAN Function Example 2
In this example, We are going to calculate the Arctangent value for all the records present in [Service Grade] using ATAN Function in SQL Server.
SELECT [EnglishProductName] ,[Color] ,[StandardCost] ,[SalesAmount] ,[Service Grade] AS Grade ,ATAN([Service Grade]) AS [Arc Tangent] FROM [Mathemetical Functions]
Thank You for Visiting Our Blog