Round decimal to the nearest whole number


  • I have a table that contains whole and decimal numbers. I would like to round decimals to their whole #s.

    Example: 21.4 should result to 21.    21.5 to 22     22. 9 to 22        21.1 to 21 etc.


    I am using sql express 2005 and web developer 2008 express.

    Also, if it possible write me the VB code, please.



    Sunday, September 14, 2008 10:37 PM

All replies

  • read about ROUND() function in Books online.


    Mathematical Functions



    declare @i decimal(9,5),@d decimal(9,5)

    set @i=21.4

    set @d=21.5

    select round(@i,0),round(@d,0)


    Madhu K Nair

    SQL Server Blog

    SQL Server 2008 Blog

    Monday, September 15, 2008 6:01 AM

    Thanks Madhu.


    Although I have sql express 2005 and web developer express 2008, I do not have any knowledge about programming. I insert grades for a school using gridview in a table. The data type is nchar.  I will be very grateful if you could help me to round the decimals to its nearest whole number.  Also, I have 3 row and 3 columns in the table, is possible to get the sum of the columns?


    Thank you,




    Monday, September 15, 2008 7:45 AM