SQL DEGREES Function

The SQL Server DEGREES function is a Mathematical function used to convert the angle measured in radians to an approximately equivalent angle measured in degrees. The syntax of the DEGREES Function is shown below.

SELECT DEGREES (Numeric_Expression)
FROM [Source]

Numeric_Expression: The SQL DEGREES function accepts exact numeric or approximately numeric data types. Remember that this function will not accept Bit data types.

SQL Server DEGREES Function Example

The SQL DEGREES function is useful to convert user-specified radians to an approximately equivalent angle in degrees. In this example, we will find the degrees of different data values (both positive and negative) and display the output.

DECLARE @i float
SET @i = 1.20

SELECT DEGREES(@i)AS [Degrees Result 1]

-- Finding Degrees directly
SELECT DEGREES(1) AS [Degrees Result 2]

SELECT DEGREES(PI()) AS [Degrees Result 3]
SELECT DEGREES(PI()/2) AS [Degrees Result 4]
SELECT DEGREES(PI()/3) AS [Degrees Result 5]

SELECT DEGREES(-6.579) AS [Degrees Result 6]
SELECT DEGREES(-4.23) AS [Degrees Result 7]
DEGREES Example 1

Within this example query, we are finding the degrees of radiant @i. We also assigned a new name to the result as ‘Result 1’ using the ALIAS Column in SQL Server.

SELECT DEGREES(@i)AS [Degrees Result 1]

In the following three statements, We used the DEGREES function directly on the positive values. Here, DEGREES(PI()) means (3.14)

SELECT DEGREES(PI()) AS [Degrees Result 3]
SELECT DEGREES(PI()/2) AS [Degrees Result 4]
SELECT DEGREES(PI()/3) AS [Degrees Result 5]

Next, We used this Mathematical function directly on the negative values.

SELECT DEGREES(-6.579) AS [Degrees Result 6]
SELECT DEGREES(-4.23) AS [Degrees Result 7]

DEGREES Example 2

In this example, we are using this SQL Server degrees function on a Mathematical functions table.

MATH TABLE SOURCE 1

For this demonstration, We are going to convert all the records present in the [Service Grade] column to equivalent degree values using this Function.

SELECT [EnglishProductName]
      ,[Color]
      ,[StandardCost]
      ,[SalesAmount]
      ,[TaxAmt]
      ,[Service Grade]
      ,DEGREES([Service Grade]) AS [Service_Degrees]
  FROM [Mathemetical Functions]
SQL DEGREES Function 2
Categories SQL