I’m trying to write an insert statement for a SQL Server table that inserts the value 1 into a decimal field. The field is of the type decimal(10, 10) which, as far as I understand, means that it can have up to 10 digits altogether, and up to 10 of those digits can be after the decimal point. But, when I try to run the insert statement I get the following error:
Arithmetic overflow error converting int to data type numeric.
If I change the data type of the field to decimal(11, 10), it suddenly works. What am I not understanding here? What am I doing wrong?
decimal(10, 10)means all decimal places, no digits to the left of the decimal point!see here: http://msdn.microsoft.com/en-us/library/aa258832(SQL.80).aspx_
decimal(11,10)gives you 1 digit the the left of the decimal and 10 to the right, so integer 1 fits now!EDIT
when using:
decimal(p,s), think ofpas how many total digits (regardless of left or right of the decimal point) you want to store, andsas how many of thosepdigits should be to the right of the decimal point.