When dealing with money, or numbers, sql server provides a few different datatypes: Decimal, Money, Float among others.
The main difference is that Decimal and Money datatypes are "exact", as opposed to Float which is a "Floating Point Representation".
When dealing with Floats, you can get some odd mathematical results:http://www.chrismay.org/2005/09/29/BinaryRepresentationOfDecimalValues.aspx
e.g. 0.4 - 0.1 = 0.300000000000000000000041.4-1.1 = 0.29999999999999999999998
So when a number is going to represent money, you should use the Decimal or Money datatypes. Money is (19,4) which means 19 total digits, 4 of which are right of the decimal point. Decimal can be setup however you want, like Decimal(10,2).
SmallMoney can also be used, which can represent money values under 1,000,000 w/ 4 decimal places.
Remember Me
Powered by: newtelligence dasBlog 2.3.9074.18820
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
E-mail
Theme design by Jelle Druyts