SQL SERVER – Math Functions Available in SQL Server

SQL SERVER - Math Functions Available in SQL Server fn The large majority of math functions is specific to applications using trigonometry, calculus, and geometry. This is very important and it is very difficult to have all of them together at place.

Math Functions

Absolute value ABS
Arc cosine ACOS
Arc sine ASIN
Arc tangent of n ATAN
Arc tangent of n and m ATN2
Smallest integer >= value CEILING
Cosine COS
Hyperbolic cosine COT
Exponential value EXP
Round down to nearest integer FLOOR
Natural logarithm LOG
Logarithm, base 10 LOG10
Modulus (remainder) USE MODULO (%) OPERATOR
Random number RAND
Sign of number SIGN
Sine SIN
Square root SQRT
Tangent TAN
Convert number if NULL ISNULL
Standard deviation STDEV
Variance VAR

Out of all the above functions, RAND is the only one which is Nondeterministic Functions. Deterministic functions always return the same result any time they are called with a specific set of input values and given the same state of the database. Nondeterministic functions may return different results each time they are called with a specific set of input values even if the database state that they access remains the same. You cannot influence the determinism of any built-in function. Each built-in function is deterministic or nondeterministic based on how the function is implemented by SQL Server.

Reference: Pinal Dave (https://blog.sqlauthority.com)

SQL Function, SQL Server
Previous Post
SQL SERVER – 2005 Understanding Trigger Recursion and Nesting with examples
Next Post
SQL SERVER – Script/Function to Find Last Day of Month

Related Posts

8 Comments. Leave new

  • is there a way to do a division and modulo in the same statement? I’d like the result of the division to go into one variable and the remainder into another.

  • how to use MOD function in sql server 2005 .

    I want record like 101 201 301 out of 100000 rows

  • How to get highest value from 5 local variables in a stored procedure.
    Declare @var1 as int, @var2 as int, @var3 as int, @var4 as int, @var5 as int
    Set @var1=55
    Set @var2=70
    Set @var3=90
    Set @var4=90
    Set @var5=25

    I need value distinct 90 as it is highest among all variables. I mentioned distinct because it repeats in @var3 and @var4 both.


    • create table temp(col1 integer)
      select * from temp

      DECLARE @temp TABLE(col1 INTEGER)
      DECLARE @r int=55
      DECLARE @s int=70
      DECLARE @t int=90
      DECLARE @q int=70
      DECLARE @x int=90
      INSERT INTO temp(col1) values(@r)
      INSERT INTO temp(col1) values(@s)
      INSERT INTO temp(col1) values(@t)
      INSERT INTO temp(col1) values(@q)
      INSERT INTO temp(col1) values(@x)

      SELECT MAX(col1) FROM temp

  • How to get a quotient of two numbers ? what is the function used to get it ?

  • SQUARE() Float expression

    Square of the given numeric expression. Equivalent of POWER function when raised to 2nd power. Example:


  • Sravan Aravapalli
    December 29, 2017 4:21 pm

    can you explain about “Convert number if NULL ISNULL”


Leave a Reply