SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


decimal


decimal

Author
Message
VM-723206
VM-723206
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1636 Visits: 267
Comments posted to this topic are about the item decimal
hakan.winther
hakan.winther
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4135 Visits: 615
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
MCITPBigGrinatabase Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
MCSE: Data Platform
ta.bu.shi.da.yu
ta.bu.shi.da.yu
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1925 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
Noel McKinney
Noel McKinney
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2607 Visits: 799
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
ta.bu.shi.da.yu
ta.bu.shi.da.yu
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1925 Visits: 494
Ah... but how would you get around that? Is there any way of disabling the rounding?

Random Technical Stuff
Noel McKinney
Noel McKinney
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2607 Visits: 799
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.

David Burrows
David Burrows
SSC-Dedicated
SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)

Group: General Forum Members
Points: 31778 Visits: 10704
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.


Bhavesh_Patel
Bhavesh_Patel
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1309 Visits: 297
Added to my knowledge base - default decimal is rounded of.



Bhavesh Patel

http://bhaveshgpatel.wordpress.com/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search