Home » SQL Server CEILING Function

SQL Server CEILING Function

SQL Server CEILING Function is a mathematical function that returns the smallest integer value that is greater than or equal to a number.





SYNTAX

CEILING ( numeric_expression )

numeric_expression
Is a numeric input value or approximate numeric data type category.

Lets look at an example of CEILING() function in SQL Server.

CEILING function with positive values

For input value 100.00

SELECT CEILING(100.00) AS OUTPUT

It returns a smallest integer value 100 that is grater than or equal to input value 100.

 

For input value 100.01

SELECT CEILING(100.01) AS OUTPUT

It returns a value 101, which is a smallest integer value that is greater than input value 100.01.

 

For input value 560.56

SELECT CEILING(560.56) AS OUTPUT

It returns a value 561, which is a smallest integer value that is greater than input value 560.56.

 

CEILING function with Negative values 

For negative input value -560.56

SELECT CEILING(-560.56) AS OUTPUT

It returns a value -560, which is a smallest integer value that is greater than input value -560.56.

 

For negative input value -00.16

SELECT CEILING(-00.16) AS OUTPUT

 

 

 

 

 

It returns a value -0, which is a smallest integer value that is greater than input value -00.16.

 

For negative input value -100.00

SELECT CEILING(-100.00) AS OUTPUT

It returns a value -100, which is a smallest integer value that is greater than input value -100.00.

RECOMMENDED..

FLOOR()




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.