SQL Server Mathematical Functions¶
The following scalar math functions perform a calculation, usually based on input values that are provided as arguments, and return a numeric value. All mathematical functions, except for RAND, are deterministic functions. This means they return the same results each time they are called with a specific set of input values. The RAND function is only deterministic when a seed parameter is specified.
Arithmetic functions, such as ABS
, CEILING
, DEGREES
, FLOOR
, POWER
, RADIANS
, and SIGN
, return a value having the same data type as the input value. Trigonometric and other functions, including EXP
, LOG
, LOG10
, SQUARE
, and SQRT
, cast their input values to float and return a float value.
Function | Description | Syntax |
---|---|---|
ABS | A mathematical function that returns the absolute (positive) value of the specified numeric expression. | ABS ( numeric_expression ) |
ACOS | A mathematical function that returns the angle, in radians, whose cosine is the specified float expression; also called arccosine. | ACOS ( float_expression ) |
ASIN | Returns the angle, in radians, whose sine is the specified float expression. This is also called arcsine. | ASIN ( float_expression ) |
ATAN | Returns the angle in radians whose tangent is a specified float expression. This is also called arctangent. | ATAN ( float_expression ) |
ATN2 | Returns the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x), where x and y are the values of the two specified float expressions. | ATN2 ( float_expression, float_expression ) |
CEILING | Returns the smallest integer greater than, or equal to, the specified numeric expression. | CEILING ( numeric_expression ) |
COS | Is a mathematical function that returns the trigonometric cosine of the specified angle, in radians, in the specified expression. | COS ( float_expression ) |
COT | A mathematical function that returns the trigonometric cotangent of the specified angle, in radians, in the specified float expression. | COT ( float_expression ) |
DEGREES | Returns the corresponding angle in degrees for an angle specified in radians. | DEGREES ( numeric_expression ) |
EXP | Returns the exponential value of the specified float expression. | EXP ( float_expression ) |
FLOOR | Returns the largest integer less than or equal to the specified numeric expression. | FLOOR ( numeric_expression ) |
LOG | Returns the natural logarithm of the specified float expression. | LOG ( float_expression ) |
LOG10 | Returns the base-10 logarithm of the specified float expression. | LOG10 ( float_expression ) |
PI | Returns the constant value of PI. | PI () |
POWER | Returns the value of the specified expression to the specified power. | POWER ( float_expression, y ) |
RADIANS | Returns radians when a numeric expression, in degrees, is entered. | RADIANS ( numeric_expression ) |
RAND | Returns a pseudo-random float value from 0 through 1, exclusive. | RAND ( [ seed ] ) |
ROUND | Returns a numeric value, rounded to the specified length or precision. | ROUND ( numeric_expression, length [ , function ] ) |
SIGN | Returns the positive (+1), zero (0), or negative (-1) sign of the specified expression. | SIGN ( numeric_expression ) |
SIN | Returns the trigonometric sine of the specified angle, in radians, and in an approximate numeric, float, expression. | SIN ( float_expression ) |
SQRT | Returns the square root of the specified float value. | SQRT ( float_expression ) |
SQUARE | Returns the square of the specified float value. | SQUARE ( float_expression ) |
TAN | Returns the tangent of the input expression. | TAN ( float_expression ) |
Differences between the ISNULL and the COALESCE system functions.