In SQL Server, the T-SQL DEGREES()
function converts a value from radians to degrees, and returns the result.
You provide the angle (specified in radians) as an argument when calling the function, and the function will return that angle in degrees.
The return value is of a data type that matches the argument.
Syntax
The syntax goes like this:
DEGREES ( numeric_expression )
Where numeric_expression is the angle specified in radians. It can be an expression of the exact numeric or approximate numeric data type category, except for the bit data type.
Example 1 – Basic Usage
Here’s a basic example.
SELECT DEGREES(1) Result;
Result:
+----------+ | Result | |----------| | 57 | +----------+
However, if we add a fractional component, here’s what happens:
SELECT DEGREES(1.0) Result;
Result:
+-----------------------+ | Result | |-----------------------| | 57.295779513082322865 | +-----------------------+
And here’s another example using a different radian value.
SELECT DEGREES(2.3) Result;
Result:
+------------------------+ | Result | |------------------------| | 131.780292880089319851 | +------------------------+
Example 2 – Passing in a Function
Here’s an example where I pass in the PI()
function.
SELECT DEGREES(PI()) Result;
Result:
+----------+ | Result | |----------| | 180 | +----------+
Example 3 – Expressions
You can also pass in expressions like this:
SELECT DEGREES(PI() / 4) Result;
Result:
+----------+ | Result | |----------| | 45 | +----------+
Convert From Degrees to Radians
If you need to convert the other way, use the T-SQL RADIANS()
function.