Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

decimal Expand / Collapse
Author
Message
Posted Tuesday, June 16, 2009 11:57 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Tuesday, July 23, 2013 6:34 AM
Points: 654, Visits: 265
Comments posted to this topic are about the item decimal
Post #736230
Posted Wednesday, June 17, 2009 2:27 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, July 3, 2014 2:45 AM
Points: 2,531, Visits: 536
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
Post #736283
Posted Wednesday, June 17, 2009 6:29 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 3, 2011 7:09 AM
Points: 258, Visits: 494
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
Post #736461
Posted Wednesday, June 17, 2009 9:05 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, February 11, 2014 4:12 PM
Points: 2,007, Visits: 768
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
Post #736676
Posted Thursday, June 18, 2009 5:33 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, July 3, 2011 7:09 AM
Points: 258, Visits: 494
Ah... but how would you get around that? Is there any way of disabling the rounding?

Random Technical Stuff
Post #737417
Posted Thursday, June 18, 2009 5:56 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, February 11, 2014 4:12 PM
Points: 2,007, Visits: 768
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.
Post #737433
Posted Thursday, June 18, 2009 7:20 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:05 AM
Points: 7,045, Visits: 6,784
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.

Post #737511
Posted Friday, December 11, 2009 4:10 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Friday, January 11, 2013 12:41 PM
Points: 621, Visits: 297
Added to my knowledge base - default decimal is rounded of.



Bhavesh Patel

http://bhaveshgpatel.wordpress.com/
Post #832809
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse