How to Format Numbers with Commas in SQL

Most of the major RDBMSs have functions that enable us to format numbers with commas as either the group separator, or the decimal separator.

Some RDBMSs also output certain numeric data types with commas in the relevant place.

Below are examples of formatting numbers with commas in some of the more popular DBMSs.

Continue reading

Fix “Arithmetic overflow error converting int to data type numeric” in SQL Server

If you’re receiving error Msg 8115, Level 16, Arithmetic overflow error converting int to data type numeric in SQL Server, it’s probably because you’re performing an operation that results in a data conversion error due to an out of range value.

This will often happen when you try to convert a number to a different data type, but it’s out of the accepted range for the new data type.

Continue reading

Fix “Arithmetic overflow error converting expression to data type int” in SQL Server

If you’re receiving error Msg 8115, Level 16, Arithmetic overflow error converting expression to data type int in SQL Server, it could be that you’re performing a calculation that results in an out of range value.

This can happen when you use a function such as SUM() on a column, and the calculation results in a value that’s outside the range of the column’s type.

Continue reading

Fix “Arithmetic overflow error converting IDENTITY to data type…” in SQL Server

If you’re getting error “Msg 8115, Level 16 Arithmetic overflow error converting IDENTITY to data type…” error in SQL Server, it’s probably because you’re trying to insert data into a table when its IDENTITY column has reached its data type’s limit.

An IDENTITY column automatically increments the value that’s inserted with each new row. If the value being inserted is out of the range of the column’s data type, then the above error will occur.

Continue reading