Use DECIMAL(p,s) for money or any figure where floating-point rounding would be wrong. Precision p can be 1 to 38 and is 10 if left out; scale s is 0 if left out.
Read more: Microsoft Learn
In the Ultra Transcenders books
Each book explains DECIMAL in context, with comparison tables and the common traps.
Terms in this definition
- WHERE
Limits a SELECT, UPDATE or DELETE to just the rows meeting a condition. Omit it, and the statement hits every row.
Related terms
- ANSI
The American National Standards Institute, which made SQL a standard in 1986, a year before ISO did. Its standard types, for example INT, DECIMAL and VARCHAR, explain why SQL looks much the same from one vendor to another, even though each has its own dialect.
- Data type
A rule limiting what a column may contain, for example INT for integers, DECIMAL for numbers with fractions or VARCHAR for text of varying length. Which types exist depends on the database product.
- Fixed decimal number
A data type, shown as Currency.Type in Power Query, that always keeps four places after the decimal point and up to 19 significant digits. It stores values exactly, unlike the floating-point Decimal number, and cuts off any extra places.
- float
An approximate numeric type based on IEEE 754. It isn't a good fit for money, rounding or testing equality; decimal is the exact type to use in those cases.