SQL Server CEILING() Function: Rounds Decimal Value

In SQL Server, the CEILING() function rounds the decimal number to the nearest integer number that is larger than or equal to the specified number.

CEILING(number)

Parameters

number: a numeric expression or decimal value.

Return Value

Returns the same type as the input expression.

Example 1:

The following example shows the CEILING value for a positive numeric and negative numeric expression.

Example: CEILING()
SELECT CEILING(23.34) AS PosInt, CEILING (-23.34) AS NegInt

You can see from the above result that CEILING() function evaluates the number on the right side of the decimal to the smallest (nearest) number greater than or equal to the input numeric expression.

Example 2:

In the below example, CEILING() of zero and a value less than one are displayed.

Example: CEILING()
SELECT CEILING(0.01) AS PosInt, CEILING (0.00) AS Result

The following table lists difference between the CEILING() and the FLOOR() function for different input value:

Input Value CEILING() FLOOR()
12.0 12 12
12.2 13 12
12.5 13 12
12.12345 13 12
-12.0 -12 -12
-12.2 -12 -13
-12.5 -12 -13
Want to check how much you know SQL Server?