MONEY (TSQL Datatype)
Is a 16-bytes decimal number (base 10) with fixed precision (=19) and scale (=4).
Syntax
MONEY
Range
Range is same as for numeric(19,4)
.
-999999999999999.9999 to 999999999999999.9999
Remarks
This datatype represents monetary or currency values, with 4 digits after decimal point.
Internally, it is stored as a numeric(19,4)
.
The difference is that converting money
to int
rounds the result, whereas numeric
is truncated to int
.
Also, operations with money
don’t change precision and scale of the result, as is the case with numeric
.
Literal Money
Any literal number prefixed with the $
symbol is parsed as money
.
$1234.50
$-45.25
Examples
DECLARE @a MONEY = 200;
PRINT (@a + $50.25) / 3; -- 'money' + 'money' --> 'money'
PRINT (@a + 50.25) / 3; -- 'money' + 'numeric' --> 'numeric'
The result is:
83.4167 <--- 'money' results are always rounded to 4 digits after decimal point
83.416666666667 <--- 'numeric' datatypes store values with maximum accuracy
If you want to have the best accuracy during arithmetic calculation, you should use
numeric
datatype for currency and monetary values, instead ofmoney
.