decimal

  • Comments posted to this topic are about the item decimal

  • Hi!

    My recommendation is to never use default values because of maintainability. What would happen if MS (I really hope they dont) changes the default value for decimal in this case? You will get a different result than expected. Thats one of the reasons I never rely on default values.

    Håkan Winther

    /Håkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform

  • I'm curious where it speaks about rounding in the linked article... I couldn't see it anywhere. It just says the default for the precision and the scale!

    Random Technical Stuff[/url]

  • ta.bu.shi.da.yu (6/17/2009)


    I'm curious where it speaks about rounding in the linked article... I couldn't see it anywhere. It just says the default for the precision and the scale!

    True, you would have to click through links at the bottom of the article to get to this page that discusses rounding:

    http://msdn.microsoft.com/en-us/library/ms191530.aspx#_decimal

  • Ah... but how would you get around that? Is there any way of disabling the rounding?

    Random Technical Stuff[/url]

  • ta.bu.shi.da.yu (6/18/2009)


    Ah... but how would you get around that? Is there any way of disabling the rounding?

    You could use SET NUMERIC_ROUNDABORT ON to get an error instead of a rounded value. Using this with the question's query gives an error message, for example

    SET NUMERIC_ROUNDABORT ON

    declare @d decimal

    select @d = 3.564636

    select @d

    [font="Courier New"]Msg 8115, Level 16, State 7, Line 7

    Arithmetic overflow error converting numeric to data type numeric.[/font]

  • ta.bu.shi.da.yu (6/18/2009)


    Ah... but how would you get around that? Is there any way of disabling the rounding?

    Use FLOOR 🙂

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Added to my knowledge base - default decimal is rounded of.



    [font="System"]Bhavesh Patel[/font]

    http://bhaveshgpatel.wordpress.com/

Viewing 8 posts - 1 through 7 (of 7 total)

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