SQL Server Interview Question #25
What is the difference between DECIMAL and FLOAT?
Data Types, Keys & Constraints Junior Beginner
Detailed Explanation
DECIMAL (also called NUMERIC) stores exact fixed-precision numeric values. FLOAT stores approximate floating-point values.
DECIMAL is normally preferred for money, prices, financial calculations, percentages requiring exact precision, and other values where rounding accuracy matters. FLOAT is useful for scientific or engineering values where approximate representation is acceptable.
For financial application code, DECIMAL should normally be used rather than FLOAT.
Code Example
DECLARE @Price DECIMAL(18,2) = 199.99;
DECLARE @Measurement FLOAT = 123.456789;
SELECT @Price AS ExactValue,
@Measurement AS ApproximateValue;