Money Data Type Precision - SQL Server (SSMS)
14,319
The number of zeroes behind the dot is called the precision
of a datatype. The money
data type has a fixed precision:
with accuracy to a ten-thousandth of a monetary unit.
That's five digits behind the dot. If you'd like a different precision, use the decimal
datatype. Some examples:
select cast(0.123456789 as money)
, cast(0.123456789 as decimal(5,3))
, cast(0.123456789 as decimal(5,1))
This prints:
0.1235 0.123 0.1
Author by
naftali
Updated on June 04, 2022Comments
-
naftali almost 2 years
In sql server management studio, data type- money, when I enter an amount with a decimal it automatically adds on zeros to fill up to the hundredths. How can I determine the amount of spaces after the decimal?
-
Chains over 12 yearsTry using 0.1000 and see what your output is... for me, it's '0.10' (missing the 3rd and 4th 0's after the decimal).
-
funkymushroom almost 11 yearsI believe that the precision is the total number of digits in the number, and the scale is how many of those are to the right of the decimal point.msdn.microsoft.com/en-us/library/aa258274%28v=sql.80%29.aspx
-
gknicker about 8 years@Andomar As demonstrated by your examples, ten-thousandths is four (not five) digits after the dot (tenths, hundredths, thousandths, ten-thousandths)
-
Dillon C over 4 yearsPrecision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2. docs.microsoft.com/en-us/sql/t-sql/data-types/…