SQL Server cast fails with arithmetic overflow

Posted by Jamie Ide on Stack Overflow See other posts from Stack Overflow or by Jamie Ide
Published on 2010-05-21T17:15:33Z Indexed on 2010/05/21 17:20 UTC
Read the original article Hit count: 390

Filed under:
|

According to the entry for decimal and numeric data types in SQL Server 2008 Books Online, precision is:

p (precision) The maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. The precision must be a value from 1 through the maximum precision of 38. The default precision is 18.

However, the second select below fails with "Arithmetic overflow error converting int to data type numeric."

SELECT CAST(123456789 as decimal(9,0))
SELECT CAST(123456789 as decimal(9,1))

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about precision