I encountered an arithmetic overflow in a simple SELECT statement. Query was as below e.g.
SELECT [SaleValue] FROM Sales
[SaleValue]
was of data type decimal(9,0)
and not a computed column.
The reason this happened was because somehow the column had a row where this field was storing a value GREATER than specified datatype, e.g. decimal(10,0)
.
I could only get the select to work when I increased the size of the column. The table in question has two other instances in two other columns and rows.
How was this situation possible? How was an out of range value saved in the column in the first place?
I'm using Microsoft SQL server + this is a base table, not a view.
decimal
- adecimal(9,0)
should occupy 5 bytes, adecimal(10,0)
9. So I think it's less likely that you could do this via editing the system tables since you won't have the correct storage size for the data in each row.