0 votes
1 view
in SQL by (20.3k points)

I have the following column specified in a database: decimal(5,2)

How does one interpret this?

According to the properties on the column as viewed in SQL Server Management studio I can see that it means: decimal(Numeric precision, Numeric scale).

What do precision and scale mean in real terms?

It would be easy to interpret this as a decimal with 5 digits and two decimals places...ie 12345.12

P.S. I've been able to determine the correct answer from a colleague but had great difficulty finding an answer online. As such, I'd like to have the question and answer documented here on StackOverflow for future reference.

1 Answer

0 votes
by (40.4k points)

The numeric precision is used for the maximum number of digits that are present in the number.

Here, 1234567.89 has a precision of 9

Whereas, the numeric scale is used for the maximum number of decimal places

Here, 123456.789 has a scale of 3

Therefore, the maximum allowed value for decimal(5,2) is 999.99

Related questions

0 votes
1 answer
0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...