SQL Server error 248: Conversion overflowed an int column
A string holding a number larger than the int range (about 2.1 billion) was converted to int. Use bigint or decimal for big numbers.
- Error number
248- Severity
- 16
- Category
- Data conversion and truncation
What it means
When converting a character value to int, SQL Server checks the range -2,147,483,648 to 2,147,483,647. A string like '3000000000', or a long numeric code such as a phone number stored as text, overflows and raises 248.
Common causes
- Phone numbers, account numbers or other long codes converted to
int. - Implicit conversion of a large numeric string to
intbecause it's compared with anintcolumn or value.
How to fix it
-
Convert to
bigintordecimalinstead.SELECT CAST('3000000000' AS bigint); -
Keep identifiers that aren't quantities (phone numbers, codes with leading zeros) as strings and compare them as strings.
Reproduce it safely
SELECT CAST('3000000000' AS int); -- Msg 248
Related errors
220Arithmetic overflow error for data type8115Arithmetic overflow error converting245Conversion failed converting a value22003PostgreSQL: numeric value out of range
More data conversion and truncation errors
8152String or binary data truncated2628Truncated in table, column241Conversion failed for date and/or time242Out-of-range date conversion8114Error converting data type512Subquery returned more than 1 value8134Divide by zero error encountered8169Conversion to uniqueidentifier failed
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.