开发者

Money Data Type Precision - SQL Server (SSMS)

In sql 开发者_Go百科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?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜