Tutorials
Search…
Practical T-SQL
Lesson 60. A Clearer Explanation Of The Parameters Of The Numeric Data Type
It is embarrassing to admit, but for seventeen years I did not understand the parameters for the numeric data type. This lesson is a plain language explanation of the Microsoft documentation that I misread for nearly two decades.
The numeric data type has two (horribly named) parameters.
numeric(precision, scale)
Precision = The total number of digits you want to store. This includes everything to the left and right of the decimal point.
Scale = Total digits you want to store to the right of the decimal point.
Microsoft’s explanation of scale is where I went off the rails.
Simply put, scale is a SUBSET of precision. Scale is included in the amount set for precision, so scale cannot be greater than or equal to precision.
Yeah, I know. I am dumb. This was NOT a good day on Stack Overflow for me.

Examples

Different Parameter Values for NUMERIC
These are the standard values I use for numeric in fact tables.
In [ ]:
NUMERIC(16,4)
In the below scenario, all values have to be less than 1.
In [ ]:
NUMERIC(16,16)
This scenario is impossible.
In [ ]:
NUMERIC(16,17)
Copy link