DECIMAL, FLOAT, and MONEY in SQL Server
The main difference is how accurately numbers are stored.
| Data type | Storage type | Precision | Best used for |
|---|---|---|---|
DECIMAL(p,s) |
Exact numeric | Configurable | Financial and business calculations |
FLOAT(n) |
Approximate numeric | Floating-point | Scientific and statistical calculations |
MONEY |
Exact monetary | Fixed at 4 decimal places | Simple currency storage |
1. DECIMAL(p,s)
Stores exact numeric values with configurable precision and scale.
-
p= total number of digits -
s= digits after the decimal point
DECIMAL(10,2)
This allows:
-
10 total digits
-
2 decimal digits
-
Maximum positive value:
99999999.99
Example:
DECLARE @Price DECIMAL(10,2) = 1250.75;
Use it for:
-
Prices
-
Tax calculations
-
Account balances
-
Interest rates
-
Financial reports
NUMERIC and DECIMAL are synonyms in SQL Server.
2. FLOAT(n)
Stores an approximate floating-point number.
DECLARE @Measurement FLOAT = 10.123456789;
It supports very large or very small values but may introduce tiny rounding differences.
DECLARE @Value FLOAT = 0.1 + 0.2;
SELECT @Value;
The internal value may be approximately:
0.30000000000000004
Use it for:
-
Scientific calculations
-
Measurements
-
Engineering data
-
Statistical calculations
Avoid it for:
-
Currency
-
Exact equality comparisons
-
Financial calculations
FLOAT(1–24) uses approximately 7 digits of precision, while FLOAT(25–53) uses approximately 15 digits. FLOAT without a value defaults to FLOAT(53).
3. MONEY
Stores an exact monetary value with exactly four decimal places.
DECLARE @Amount MONEY = 1250.7567;
Range:
-922,337,203,685,477.5808
to
922,337,203,685,477.5807
Use it for simple monetary values when four decimal places are sufficient.
However, MONEY is usually avoided for complex financial calculations because its fixed scale and calculation behavior can cause rounding issues, especially during multiplication and division.
For most financial systems, prefer:
DECIMAL(19,4)
Example
CREATE TABLE Product
(
Price DECIMAL(18,2), -- Exact price
Weight FLOAT, -- Approximate measurement
LegacyPrice MONEY -- Fixed four-decimal monetary value
);
Key interview points
-
DECIMALstores exact values with configurable precision and scale. -
FLOATstores approximate values and can introduce rounding differences. -
MONEYis exact but has a fixed scale of four decimal places. -
Use
DECIMALfor money, tax, banking and accounting calculations. -
Use
FLOATfor scientific or measurement data where approximation is acceptable. -
Do not compare
FLOATvalues using exact equality when precision matters. -
MONEYdoes not store a currency symbol or currency type; store the currency code separately. -
In most modern financial applications,
DECIMAL(19,4)is safer and more flexible thanMONEY.