Automatic decimal round off

  • Automatic decimal round off is happening for a column having datatype Decimal (6,2).

    I am entering 10.5 in the UI & it is rounding off & saved as 11.

    Should I change the datatype here to Nvarchar?

  • NO.  DO NOT store decimals as varchar.

    Find the error in the code that is doing the rounding.  What data types are being used in the UI?

    Trace the call to the DB, and validate that the values are being passed as decimal, and not int.

  • have you run a sql profiler trace to see what the  client app is  trying to do - sounds like the UI is doing the rounding for you

    MVDBA

  • This is a UI or coding issue, not a database issue.

    Decimal (6,2) is an pretty small number.  That can only hold +- 9999.99.

    10.5 assigned to a integer type in a programming language is likely rounding this number to 11.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply