SQL Server error 220: Arithmetic overflow error for data type
A constant or result doesn't fit in a small integer type such as tinyint or smallint. The message shows the type and the value.
- Error number
220- Severity
- 16
- Category
- Data conversion and truncation
What it means
Error 220 is raised when a value is too large (or negative, for tinyint) for an integer type, typically when assigning a constant or a computed integer: tinyint holds 0 to 255, smallint -32,768 to 32,767. It is closely related to 8115, which covers conversions such as decimal overflow.
Common causes
- Storing a value over 255 in a
tinyint, or a negative value in one. - An identity or counter column defined as
tinyintorsmallintrunning out of range. - Arithmetic on small integer columns whose result exceeds the type.
How to fix it
-
Use a wider type for the column or variable.
ALTER TABLE dbo.Settings ALTER COLUMN RetryCount smallint NOT NULL;
-
Cast before doing arithmetic so the result has room.
SELECT CAST(a AS int) * b FROM dbo.SmallNumbers;
Reproduce it safely
DECLARE @t tinyint = 256; -- Msg 220: Arithmetic overflow error for data type tinyint, value = 256.
Related errors
8115Arithmetic overflow error converting248Conversion overflowed an int column22003PostgreSQL: numeric value out of range1264MySQL: Out of range value for column
More data conversion and truncation errors
8152String or binary data truncated2628Truncated in table, column245Conversion failed converting a value241Conversion failed for date and/or time242Out-of-range date conversion8114Error converting data type512Subquery returned more than 1 value8134Divide by zero error encountered
The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.
Work on SQL Server in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.