CEILING (Transact‑SQL)
Returns the smallest integer greater than, or equal to, the specified numeric expression.
Syntax
CEILING ( numeric_expression )
Parameters
| Parameter | Description |
|---|---|
numeric_expression | A valid numeric expression of type int, bigint, smallint, tinyint, decimal, numeric, float, or real. The expression can be a column, a variable, or any valid numeric expression. |
Return Types
The return type is the same as the input type, except float and real always return float.
Remarks
- If
numeric_expressionis already an integer value,CEILINGreturns the same value. - For negative numbers,
CEILINGreturns the integer that is less negative (i.e., closer to zero). - When used with
decimalornumeric, the scale of the result is 0.
Examples
Basic usage
SELECT CEILING(4.2) AS Result1,
CEILING(-4.2) AS Result2,
CEILING(5) AS Result3;
-- Result1: 5
-- Result2: -4
-- Result3: 5
Interactive Demo
Enter a numeric value to see the CEILING result.