Jump to content

Recommended Posts

I have setup the following table:-

IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
      WHERE TABLE_NAME = 'theoreticalHold')
   DROP TABLE theoreticalHold
GO
CREATE TABLE THold (
pid int NOT NULL IDENTITY(1,1),
TS NUMERIC(2,2) NOT NULL,
TR NUMERIC(2,2) NOT NULL,
TB NUMERIC(2,2) NOT NULL,
TP NUMERIC(2,2) NOT NULL,
TP2 NUMERIC(2,2) NOT NULL,
filler1 NUMERIC(2,2) NOT NULL,
filler2 NUMERIC(2,2) NOT NULL,
filler3 NUMERIC(2,2) NOT NULL,
PRIMARY KEY (pid)
);

 

and now I am trying to execute the following insert statement in Enterprise Manager

INSERT INTO theoreticalHold  VALUES (5.40, 2.40, 1.00, 1.15, 2.40, 0,0,0);

and it fails with

Server: Msg 8115, Level 16, State 8, Line 1

Arithmetic overflow error converting numeric to data type numeric.

The statement has been terminated.

 

I do not understand the necessity of converting numeric to numeric.

Please tell me what I have done wrong.

Link to comment
https://forums.phpfreaks.com/topic/123939-inserting-decimal-values-failing/
Share on other sites

when declaring a numeric datatype, the first number is max length of the number (including decimals) and the second is how many numbers can come after the decimal. so, 5.40 is 3 numbers. make your datatype definitions like so:

NUMERIC(3,2)

or better yet,

NUMERIC(5,2)

to be safe

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.