ASIN() Examples in SQL Server

Using SQL Server, you can use the T-SQL ASIN() function to return the arcsine of a number. In other words, this function returns the angle, in radians, whose sine is the specified float expression.

The return data type is float.

You provide the number as an argument when calling the function.

Syntax

The syntax goes like this:

ASIN ( float_expression )

Where float_expression is an expression of either type float or of a type that can implicitly convert to float. Only a value ranging from -1.00 to 1.00 is valid.

Example 1 – Basic Usage

Here’s a basic example.

SELECT ASIN(0.1) Result;

Result:

+------------------+
| Result           |
|------------------|
| 0.10016742116156 |
+------------------+

Here’s what happens when you provide a value of 1.

SELECT ASIN(1) Result;

Result:

+-----------------+
| Result          |
|-----------------|
| 1.5707963267949 |
+-----------------+

And here’s what happens when you provide a value of -1.

SELECT ASIN(-1) Result;

Result:

+------------------+
| Result           |
|------------------|
| -1.5707963267949 |
+------------------+

Example 2 – Out-Of-Range Values

Providing a value outside the range -1 to 1 returns an error.

SELECT ASIN(2) Result;

Result:

Msg 3623, Level 16, State 1, Line 1
An invalid floating point operation occurred.
Time: 0.322s

Example 3 – Expressions

You can also pass in expressions like this:

SELECT ASIN(0.1 + 0.3) Result;

Result:

+-------------------+
| Result            |
|-------------------|
| 0.411516846067488 |
+-------------------+

Example 4 – Zero

Zero is within the accepted range.

SELECT ASIN(0) Result;

Result:

+----------+
| Result   |
|----------|
| 0        |
+----------+

Example 5 – NULL

Passing in NULL returns NULL.

SELECT ASIN(NULL) Result;

Result:

+----------+
| Result   |
|----------|
| NULL     |
+----------+

Return the Arc Cosine

You can also return the arccosine of a value using the TSQL ACOS() function.