Summary: in this tutorial, you will learn how to use the SQL Server ASIN()
function to return the arcsine of a number.
Introduction to the SQL Server ASIN() function
The arcsine function is the inverse function of the sine function. The arcsine function returns the angle of a sine in radians.
In SQL Server, you can use the ASIN()
function to return an angle (in radians) of a specified sine.
The following shows the syntax of the ASIN()
function:
ASIN(n)
Code language: SQL (Structured Query Language) (sql)
In this syntax:
n
is a float value you want to calculate the arcsine. The valid range ofn
is from -1 to 1.
The ASIN()
function returns an angle (in radians) whose sine equals the n
. If n
is invalid, the ASIN()
function will raise an error. If n
is NULL
, the ASIN()
function will return NULL
.
SQL Server ASIN() function examples
Let’s take some examples of using the SQL Server ASIN()
function.
1) Basic SQL Server ASIN() function example
The following example uses the ASIN()
function to return the arcsine of 1:
SELECT ASIN(1) angle;
Code language: SQL (Structured Query Language) (sql)
Output:
angle
----------------
1.5707963267949
Code language: SQL (Structured Query Language) (sql)
2) Using ASIN() function with variables
The following example uses the ASIN()
function with variables:
DECLARE @value FLOAT;
SET @value = 0;
SELECT ASIN(@value) AS arcsine_value;
Code language: SQL (Structured Query Language) (sql)
Output:
arcsine_value
-------------
0
Code language: SQL (Structured Query Language) (sql)
In this example, we set the @value
to 0 and then use the ASIN()
function to calculate the arcsine of 0, which is zero radians.
Summary
- Use the
ASIN()
function to return the arcsine of a number.