In SQL Server, the T-SQL RADIANS()
function converts a value from degrees to radians, and returns the result.
You provide the angle (specified in degrees) as an argument when calling the function, and the function will return that angle in radians.
The return value is uses the same data type as the argument.
Syntax
The syntax goes like this:
RADIANS ( 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 RADIANS(180) Result;
Result:
+----------+ | Result | |----------| | 3 | +----------+
However, if I add a fractional component, here’s what happens:
SELECT RADIANS(180.0) Result;
Result:
+----------------------+ | Result | |----------------------| | 3.141592653589793116 | +----------------------+
And here’s another example using a different value.
SELECT RADIANS(20.3) Result;
Result:
+----------------------+ | Result | |----------------------| | 0.354301838154848892 | +----------------------+
However, here’s what happens if I don’t include the fractional part:
SELECT RADIANS(20) Result;
Result:
+----------+ | Result | |----------| | 0 | +----------+
Example 2 – Expressions
You can also pass in expressions like this:
SELECT RADIANS(45 * 4) Result;
Result:
+----------+ | Result | |----------| | 3 | +----------+
That’s effectively the same as doing this:
SELECT RADIANS(180) Result;
Result:
+----------+ | Result | |----------| | 3 | +----------+
Convert From Degrees to Radians
If you need to convert the other way, use the T-SQL DEGREES()
function.