Thursday, April 20, 2017

CEILING() in SQL Server


SQL CEILING() function is opposite of FLOOR(). It is used to return the smallest integer greater or equal to, the specified values. NULL values are not rounded off. CEILING() does not work on non-numeric columns such as text.


Syntax:

     
            SELECT CEILING (numeric_expression)


numeric_expression is the numeric value of which floor value is to be calculated.


Example 1:
CEILING() on numeric column.

SELECT * FROM TempEmployeePayHistory




SELECT Rate, CEILING(Rate) FROM TempEmployeePayHistory
  



Example 2:
CEILING() on column with NULL values.

          SELECT * FROM TempEmployeePayHistory
  



SELECT Rate, CEILING(Rate) FROM TempEmployeePayHistory




Example 3:
CEILING() on text column.

          SELECT * FROM DatabaseLog




          SELECT [Event], CEILING([Event]) FROM DatabaseLog




Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: