SQL DEGREES Function

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

SELECT DEGREES (Numeric_Expression)
FROM [Source]

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

SQL DEGREES Function Example 1

The DEGREES Function is used to convert user specified radians to an approximately equivalent angle in degrees. In this example, We are going to find the degrees of different data values (both positive and negative values) 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]
SQL DEGREES Function 1

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

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

In the following three statements, We used DEGREES function directly on the positive values. Here, DEGREES(PI()) means DEGREES(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 DEGREES Mathematical function directly on the negative values

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

DEGREES Function Example 2

In this example, we are using this SQL server degrees function on a Mathematical functions table. For this demonstration, We are going to convert all the records present in the [Service Grade] column to equivalent degree values using this DEGREES Function.

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