Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Money data or Decimal Data type in sql server to store costing values? [duplicate]

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 ?

like image 803
user3378215 Avatar asked Mar 12 '14 06:03

user3378215


People also ask

What data type should I use for money SQL?

"The MONEY data type could result in unintentional loss of precision from rounding errors. It's better to use the DECIMAL data type."

Which data type is best for currency amounts in SQL Server?

If you need the highest precision, a DECIMAL can use up to 17 bytes for each value. Generally though, I like using DECIMAL(19,4) for currency, which needs 9 bytes and can store numbers 19 digits wide, where the last four digits are after the decimal place.

Which data type is used to stores money value?

The MONEY data type stores currency amounts. TLike the DECIMAL(p,s) data type, MONEY can store fixed-point numbers up to a maximum of 32 significant digits, where p is the total number of significant digits (the precision) and s is the number of digits to the right of the decimal point (the scale).

What is the difference between money and decimal data types in SQL Server?

Money is stored in the same way an integer is stored, whereas decimal is stored as a decimal point and decimal digits. This means that money will drop accuracy in most cases, while decimal will only do so when converted back to its original scale. Money is fixed point, so its scale doesn't change during calculations.


1 Answers

You should prefer decimal as money datatype is not precise.

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

like image 90
Rahul Tripathi Avatar answered Oct 27 '22 22:10

Rahul Tripathi