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.
Best Answer
This can happen in several ways, for example as described in Troubleshooting DBCC error 2570 in SQL Server 2005 and later versions:
That article contains a lot of useful information on the topic. For the basics, see the documentation for
DBCC CHECKDB
and theDATA_PURITY
option in particular.