|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Saturday, April 06, 2013 12:20 AM
Points: 649,
Visits: 263
|
|
| Comments posted to this topic are about the item decimal
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 5:31 AM
Points: 2,226,
Visits: 438
|
|
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
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Sunday, July 03, 2011 7:09 AM
Points: 258,
Visits: 494
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, April 05, 2012 2:35 PM
Points: 2,007,
Visits: 767
|
|
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
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Sunday, July 03, 2011 7:09 AM
Points: 258,
Visits: 494
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, April 05, 2012 2:35 PM
Points: 2,007,
Visits: 767
|
|
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
Msg 8115, Level 16, State 7, Line 7 Arithmetic overflow error converting numeric to data type numeric.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: 2 days ago @ 11:13 AM
Points: 6,351,
Visits: 5,369
|
|
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.
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Friday, January 11, 2013 12:41 PM
Points: 621,
Visits: 297
|
|
|
|
|