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 DEGREES function accepts exact numeric or approximately numeric data types. Remember that this function will not accept Bit data types.

Return Value: The DEGREES function returns the angle in degrees and the same data type as the argument.

SQL Server DEGREES Function Example

This 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.

Basic DEGREES() function example

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. Please refer to the list of SQL Math functions from our SQL Server Programming page.

DECLARE @i float
SET @i = 1.20

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

The following query finds the degrees of a positive number 1.

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

Using the DEGREES() function with the PI value

In the following three SELECT 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]

Using the DEGREES() function with a negative value

Next, we used the DEGREES method directly on the negative values. Please refer to the SQL RADIANS and SQL EXP functions from the list of Mathematical functions

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

Using the DEGREES() function with table data

In this SQL SELECT example, we are using the 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 Function.

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