The SQL RADIANS function is a Mathematical function used to convert an angle measured in degrees to an approximately equivalent angle measured in radians. The syntax of the SQL Server RADIANS Function is
SELECT RADIANS (numeric_Expression) FROM [Source]
SQL Server RADIANS function accepts exact numeric (Numeric_Expression) or approximately numeric data types. It will not accept the Bit data type.
SQL RADIANS Function Example
The RADIANS Function allows you to convert degrees to an approximately equivalent angle measured in radians. In this example, We are going to find the radians of different data (both the positive and negative values) and display the output
DECLARE @i INT SET @i = 120 SELECT RADIANS(@i)AS [Radians Result 1] -- Finding Degrees directly SELECT RADIANS(1) AS [Radians Result 2] SELECT RADIANS(90) AS [Radians Result 3] SELECT RADIANS(60) AS [Radians Result 4] SELECT RADIANS(45) AS [Radians Result 5] SELECT RADIANS(-30) AS [Radians Result 6] SELECT RADIANS(-140.579) AS [Radians Result 7]
Within this radians function example query, we are calculating the radiant value of degree @i. We also assigned a new name ‘Radians Result 1’ using ALIAS Column in SQLServer.
SELECT RADIANS(@i)AS [Radians Result 1]
In the following multiple statements, we used the RADIANS function directly on the positive float values.
SELECT RADIANS(90) AS [Radians Result 3] SELECT RADIANS(60) AS [Radians Result 4] SELECT RADIANS(45) AS [Radians Result 5]
Next, We used this SQL RADIANS function directly on the negative float values
SELECT RADIANS(-30) AS [Radians Result 6] SELECT RADIANS(-140.579) AS [Radians Result 7]
RADIANS Function Example 2
In this example, we are using the radians function on the existing product Sales table. For this Mathematical function demonstration, we are going to convert all the records that are present in the [StandardCost] and [ListPrice] columns to equivalent radiant values using RADIANS Function.
SELECT [EnglishProductName] ,[Color] ,[StandardCost] ,RADIANS([StandardCost]) AS [Cost_Radian result] ,[ListPrice] ,RADIANS([ListPrice]) AS [List_Radian result] ,[DealerPrice] ,[SalesAmount] FROM [Product Sales]