Sunday, February 19, 2012

Data type problem

Arithmetic overflow error converting numeric to data type numeric.
I'm getting this error when I'm trying to insert.
this is my SQL
insert into ABSCTRL
( ID, column1 )
values ('123',12)
ID is char (4)
Column1 is decimal(4,1) in the database table.
Please let me know why I'm getting this error.
Thanks
ChandraAre you quite certain you got the data types right?
ML
http://milambda.blogspot.com/|||Can you post the table script?|||yes..I was right about the data types. Why my insert statement is not workin
g'
"ML" wrote:

> Are you quite certain you got the data types right?
>
> ML
> --
> http://milambda.blogspot.com/|||Hi Chandra,
If your datatype is right, then the problem is with the value you are
trying to insert.
If your column1 datatype is decimal(4,1)
then the value you will have to insert should be between -1000 and 1000
(limits excluded). If not it will give an error that you mentioned.
Can you post the table create script and the insert that you tried to perfor
m.|||There's something else going on. Below does not return any errors:
CREATE TABLE ABSCTRL
(ID char (4),
Column1 decimal(4,1) )
insert into ABSCTRL
( ID, column1 )
values ('123',12)
SELECT * FROM ABSCTRL
If the table definition and the INSERT corresponds to your envoronment, then
it could be an inert
trigger on the ABSCTRL table.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Chandra" <Chandra@.discussions.microsoft.com> wrote in message
news:A77E1CD0-9FB7-417B-B926-1DE794713ABD@.microsoft.com...
> Arithmetic overflow error converting numeric to data type numeric.
> I'm getting this error when I'm trying to insert.
> this is my SQL
> insert into ABSCTRL
> ( ID, column1 )
> values ('123',12)
> ID is char (4)
> Column1 is decimal(4,1) in the database table.
> Please let me know why I'm getting this error.
>
> Thanks
> Chandra
>|||This is my SQL Script
CREATE TABLE [dbo].[ABSCTRL] (
[ID] [char] (4) NOT NULL ,
[column1] [decimal](1, 0) NOT NULL ,
) ON [PRIMARY]
GO
I don't know why I'm getting [decimal](1, 0) because in design I gave
length as 4 and precision as 1. Pleaselet me know where I made a mistake.
"Tibor Karaszi" wrote:

> There's something else going on. Below does not return any errors:
> CREATE TABLE ABSCTRL
> (ID char (4),
> Column1 decimal(4,1) )
>
> insert into ABSCTRL
> ( ID, column1 )
> values ('123',12)
> SELECT * FROM ABSCTRL
>
> If the table definition and the INSERT corresponds to your envoronment, th
en it could be an inert
> trigger on the ABSCTRL table.
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Chandra" <Chandra@.discussions.microsoft.com> wrote in message
> news:A77E1CD0-9FB7-417B-B926-1DE794713ABD@.microsoft.com...
>
>|||you should have given the precision as 4 and scale as 1
you had declared it wrong. Change it and try it.|||Thanks a lot.. it's working!!!
"Omnibuzz" wrote:

> you should have given the precision as 4 and scale as 1
> you had declared it wrong. Change it and try it.

No comments:

Post a Comment