SQL Server Mathematical Functions
This page lists the commonly used mathematical functions in SQL Server.
For an angle calculated from both X and Y coordinates, use ATN2(y, x); ATAN() takes only a tangent ratio and returns an angle in the range -π/2 through π/2.
-
ABS
Use SQL Server ABS() to return a numeric expression’s absolute value, while accounting for its input-dependent return type and minimum-integer overflow. -
ACOS
Use SQL Server ACOS() to return the arccosine in radians for a float input from -1 through 1. -
ASIN
Use SQL Server ASIN() to return the arcsine in radians for a float input from -1 through 1. -
ATAN
Use SQL Server ATAN() to return the arctangent in radians for a float expression representing a tangent ratio. -
ATN2
Use SQL Server ATN2(y, x), the T-SQL atan2 function, to calculate an angle from two coordinates while preserving the quadrant. -
CEILING
Use SQL Server CEILING() to return the smallest integer greater than or equal to a value; the return type depends on the input. -
COS
Use SQL Server COS() to return the cosine of an angle measured in radians; the return type is float. -
COT
Use SQL Server COT() to return the cotangent of an angle in radians as a float value. -
DEGREES
Use SQL Server DEGREES() to convert radians to degrees; its return type depends on the numeric input type. -
EXP
Use SQL Server EXP() to calculate e raised to a numeric expression; the function accepts float-convertible input and returns float. -
FLOOR
Use SQL Server FLOOR() to round down to the greatest integer less than or equal to a numeric value; the return type depends on the input. -
LOG
Use SQL Server LOG() for the natural logarithm or, from SQL Server 2012, specify another logarithm base. -
LOG10
Use SQL Server LOG10() to return the base-10 logarithm of a float expression as a float value. -
PI
ThePI()function is used to return the value of Pi, which is approximately equal to 3.14159265358979. -
POWER
The SQL ServerPOWER()function is used to return a given expression raised to the specified power. -
RADIANS
Use SQL Server RADIANS() to convert degrees to radians; its return type follows the input, so cast integer angles for fractional precision. -
RAND
In SQL Server, theRAND()function is used to generate a random number. -
ROUND
Use SQL Server ROUND() to round to positive or negative precision; the optional third argument truncates instead of rounding. -
SIGN
Use SQL Server SIGN() to return 1, 0, or -1 according to a numeric expression’s sign; the return type depends on the input. -
SIN
The SQL ServerSIN()function is a mathematical function used to return the sine value of a given angle. -
SQRT
Use SQL Server SQRT() to return the square root of a numeric expression as a float value. -
TAN
Use SQL Server TAN() to return the tangent of a radian-valued float expression.