# Thread: Decimal or Numeric Precision issue.

1. Registered User
Join Date
Apr 2008
Posts
20

## Unanswered: Decimal or Numeric Precision issue.

Hi,
In sybase manuals it is given that precision specifies the maximum number of decimal digits that can be stored in the column. It includes all digits to the right or left of the decimal point.

But when i tried to insert a 22 digits number into a column ,whose column precision is 22 .It giving error. See the following code snippet. Same is happening with the decimal also .
Code:
```create table test_scale_prec(col1 numeric(22,6)   not null)
go

insert into test_scale_prec values(12345678901234567890.12)
go
/*Failed
Msg 247, Level 16, State 1:
Server 'MAP_DEV', Line 2:
Arithmetic overflow during implicit conversion of NUMERIC value
'12345678901234567890.12' to a NUMERIC field .
*/```
Some one please tell me how to resolve this problem

2. Registered User
Join Date
May 2005
Location
South Africa
Posts
1,369
The number you insert is to large
did you maybe intend numeric(22,2) else
you need a numeric(26,6) -- 26 digits of which 6 is decimals

3. Registered User
Join Date
Apr 2008
Posts
20
But in the manuals it is given that precision is the maximum no of digits can be used.

4. Registered User
Join Date
May 2005
Location
South Africa
Posts
1,369
Yes, the number of digits to the left and right of the decimal point

5. Registered User
Join Date
Apr 2008
Posts
20
Then it should allow me to insert a value contains 22 digits right.

6. vaguely human
Join Date
Jun 2007
Location
London
Posts
2,527
Originally Posted by mohanrao
Some one please tell me how to resolve this problem
What pdreyer is saying is totally correct but I'll try and explain it differently to you.

You have defined the field to be numeric(22,6). This means it will be precise up to 22 digits in total but 6 of those digits are after the decimal point ie 0.123456. This means you can have 16 digits (22 - 6) as the integer part before the decimal point ie 1234567890123456. This means the whole number can look like this 1234567890123456.123456

You got an error because you tried to insert a 20 digit integer part into a field that will only hold 16 digits in the integer part. Reading back I'm not sure whether this description helped or not - oh well.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•