SQL Server CEILING() Function

The CEILING() function in SQL Server rounds a number *up* to the nearest integer.



CEILING(): Definition and Usage

This function is useful when you need to work with whole numbers and want to always round up to the next integer, discarding any fractional part. It always rounds towards positive infinity.

Related Functions

For similar operations, you might also find the FLOOR() function (rounding down) and the ROUND() function (rounding to a specified number of decimal places) helpful.

Syntax

Syntax

CEILING(number)
      

Parameter Values

Parameter Description
number The numeric value you want to round up. This is required.

Examples

Rounding a Number Up

This example shows how CEILING(25.75) rounds up to 26.

Syntax

SELECT CEILING(25.75) AS CeilValue;
      
Output

26
      

Rounding an Integer Up

CEILING() will return the same integer if the input is already a whole number.

Syntax

SELECT CEILING(25) AS CeilValue;
      
Output

25
      

Rounding a Negative Number Up

For negative numbers, CEILING() rounds towards positive infinity.

Syntax

SELECT CEILING(-13.5) AS CeilValue;
      
Output

-13
      

Technical Details

The CEILING() function is available in:

  • SQL Server (starting with version 2008)
  • Azure SQL Database
  • Azure SQL Data Warehouse
  • Parallel Data Warehouse