Menu

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.

For reciprocal angle functions, see COT() and TAN().

  1. 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.
  2. ACOS

    Use SQL Server ACOS() to return the arccosine in radians for a float input from -1 through 1.
  3. ASIN

    Use SQL Server ASIN() to return the arcsine in radians for a float input from -1 through 1.
  4. ATAN

    Use SQL Server ATAN() to return the arctangent in radians for a float expression representing a tangent ratio.
  5. ATN2

    Use SQL Server ATN2(y, x), the T-SQL atan2 function, to calculate an angle from two coordinates while preserving the quadrant.
  6. CEILING

    Use SQL Server CEILING() to return the smallest integer greater than or equal to a value; the return type depends on the input.
  7. COS

    Use SQL Server COS() to return the cosine of an angle measured in radians; the return type is float.
  8. COT

    Use SQL Server COT() to return the cotangent of an angle in radians as a float value.
  9. DEGREES

    Use SQL Server DEGREES() to convert radians to degrees; its return type depends on the numeric input type.
  10. EXP

    Use SQL Server EXP() to calculate e raised to a numeric expression; the function accepts float-convertible input and returns float.
  11. 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.
  12. LOG

    Use SQL Server LOG() for the natural logarithm or, from SQL Server 2012, specify another logarithm base.
  13. LOG10

    Use SQL Server LOG10() to return the base-10 logarithm of a float expression as a float value.
  14. PI

    The PI() function is used to return the value of Pi, which is approximately equal to 3.14159265358979.
  15. POWER

    The SQL Server POWER() function is used to return a given expression raised to the specified power.
  16. RADIANS

    Use SQL Server RADIANS() to convert degrees to radians; its return type follows the input, so cast integer angles for fractional precision.
  17. RAND

    In SQL Server, the RAND() function is used to generate a random number.
  18. ROUND

    Use SQL Server ROUND() to round to positive or negative precision; the optional third argument truncates instead of rounding.
  19. 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.
  20. SIN

    The SQL Server SIN() function is a mathematical function used to return the sine value of a given angle.
  21. SQRT

    Use SQL Server SQRT() to return the square root of a numeric expression as a float value.
  22. TAN

    Use SQL Server TAN() to return the tangent of a radian-valued float expression.