We are receiving the following error when inserting our data into a SQL Server table:

Arithmetic overflow error converting numeric to data type numeric

The data we are inserting looks like this:

INSERTED.ID VALUES(0, 'Blah Blah', 6202, 2, -697937977842128, -179239499006078, 529122280867677, -682697977842128, -163999499006078, 529445721858303, -690317977842128, -171619499006078, 52928400136299, 1000)

But the column definitions for the big numbers are all Decimal(18,9) so I am not sure why we are getting this error.

  • 8
    Decimal(18,9) means the integer part can be no more than 9 digits (18-9). – mustaccio Jan 18 at 19:21

As mustaccio pointed out, when you define a DECIMAL or NUMERIC data type in SQL Server, the first parameter in the declaration is the precision meaning how many total digits between both sides of the decimal point can be stored. The second parameter is the scale which is how many of those total digits can be stored to the right side of the decimal. (Therefore the total number of digits that can be stored to the left side of the decimal is the precision - scale.)

You can read more information about those data types in the Microsoft Docs - decimal and numeric (Transact-SQL).

  • Thanks. I feel like such a newbie!!! – Peter Jan 18 at 20:36
  • @Peter No sweat, it's a minor detail I've overlooked my first few years working with SQL Server too. – J.D. Jan 18 at 21:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.