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:
nis a float value you want to calculate the arcsine. The valid range ofnis 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.5707963267949Code 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
-------------
0Code 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.