何时在sql server中使用Money数据或十进制数据类型来存储成本核算值? [重复]

时间:2021-12-14 16:55:28

This question already has an answer here:

这个问题在这里已有答案:

What is preferable data type to store the costing value ? Money or Decimal whats the programmatic diff bet them? asp.net Data Annotation for asp.net Model for Money data type ?

存储成本核算值的首选数据类型是什么? Money还是Decimal什么是程序化差异打赌他们? asp.net Data for Money数据类型的asp.net数据注释?

2 个解决方案

#1


13  

Decimal type provides more precision to hold intermediate results to get the results you expect.

十进制类型提供更高的精度来保存中间结果以获得您期望的结果。

Disadvantages of money datatype:

money数据类型的缺点:

  1. It is proprietary, so porting it is a pain. It is one of the many "Sybase Code Museum" features from decades ago. Remember the early versions of UNIX?

    它是专有的,所以移植它是一种痛苦。它是几十年前众多“Sybase代码博物馆”的特色之一。还记得UNIX的早期版本吗?

  2. Writing code in dialect when you don't need to make you sound like a hillbilly to people that speak the language. You are better off with DECIMAL(s,p) so you can use a properly sized column.

    当你不需要让那些说英语的人听起来像乡巴佬时,用方言编写代码。你最好使用DECIMAL(s,p),这样你就可以使用适当大小的列。

  3. It does display and formatting in the back end, with commas and dollar signs. That defeats the purpose of a tiered architecture.

    它在后端显示和格式化,带有逗号和美元符号。这违背了分层架构的目的。

  4. The MONEY data type has rounding errors.

    MONEY数据类型具有舍入错误。

Ref:msdn

参考:MSDN

#2


4  

You should prefer decimal as money datatype is not precise.

你应该更喜欢十进制,因为money数据类型不精确。

You may also check Performance / Storage Comparisons : MONEY vs. DECIMAL by Aaron Bertrand

您还可以通过Aaron Bertrand检查性能/存储比较:MONEY与DECIMAL

#1


13  

Decimal type provides more precision to hold intermediate results to get the results you expect.

十进制类型提供更高的精度来保存中间结果以获得您期望的结果。

Disadvantages of money datatype:

money数据类型的缺点:

  1. It is proprietary, so porting it is a pain. It is one of the many "Sybase Code Museum" features from decades ago. Remember the early versions of UNIX?

    它是专有的,所以移植它是一种痛苦。它是几十年前众多“Sybase代码博物馆”的特色之一。还记得UNIX的早期版本吗?

  2. Writing code in dialect when you don't need to make you sound like a hillbilly to people that speak the language. You are better off with DECIMAL(s,p) so you can use a properly sized column.

    当你不需要让那些说英语的人听起来像乡巴佬时,用方言编写代码。你最好使用DECIMAL(s,p),这样你就可以使用适当大小的列。

  3. It does display and formatting in the back end, with commas and dollar signs. That defeats the purpose of a tiered architecture.

    它在后端显示和格式化,带有逗号和美元符号。这违背了分层架构的目的。

  4. The MONEY data type has rounding errors.

    MONEY数据类型具有舍入错误。

Ref:msdn

参考:MSDN

#2


4  

You should prefer decimal as money datatype is not precise.

你应该更喜欢十进制,因为money数据类型不精确。

You may also check Performance / Storage Comparisons : MONEY vs. DECIMAL by Aaron Bertrand

您还可以通过Aaron Bertrand检查性能/存储比较:MONEY与DECIMAL