Reputation: 103
im trying to insert the following data into the Table in MSSQL.
(1, 'Tony', NULL ,1.81, 65.43, 0, '1957-05-10', NULL),
(2, 'Mark', NULL ,1.81, 65.43, 0, '1957-05-10', NULL),
(3, 'Tanya', 5 ,1.81, 65.43, 1, '1957-05-10', NULL),
(4, 'Марк', NULL ,1.81, 65.43, 0, '1957-05-10','Dura bura'),
(5, 'Toncho', 2 ,1.81, 65.43, 0, '1957-05-10','Сто чадъра')
Unfortunately I get 'Arithmetic overflow error converting numeric to data type numeric' and I have no idea why. Here is the code and I just cannot understand why it doesn't work. I tried reading other posts, but I am just starting and I cannot understand most of what is written in the other problem/suggestions :(
CREATE DATABASE Human
USE Human
CREATE TABLE People
(
Id INT PRIMARY KEY,
[Name] NVARCHAR(200) NOT NULL,
Picture VARBINARY(MAX),
Height DECIMAL(5,2),
[Weight] DECIMAL(5,2),
Gender BIT NOT NULL,
Birthdate DATETIME NOT NULL,
Biography NVARCHAR(MAX)
)
INSERT INTO People(Id, [Name], Picture, Height, [Weight], Gender, Birthdate, Biography) VALUES
(1, 'Tony', NULL ,1.81, 65.43, 0, '1957-05-10', NULL),
(2, 'Mark', NULL ,1.81, 65.43, 0, '1957-05-10', NULL),
(3, 'Tanya', 5 ,1.81, 65.43, 1, '1957-05-10', NULL),
(4, 'Марк', NULL ,1.81, 65.43, 0, '1957-05-10','Dura bura'),
(5, 'Toncho', 2 ,1.81, 65.43, 0, '1957-05-10','Сто чадъра')
Upvotes: 0
Views: 163
Reputation: 103
Thank you all. I believe I had some leftovers in the DB or somewhere else that I had not cleared and it was interfering with the code. Restarting the program, deleting everything(i had to delete the DB too or it just happened to work when I did), reconnecting and writing it from scratch solved this issue. Exact code as per request. I was running only the INSERT part when I received the issue. I cannot seem to run the whole code in one go, I must execute it line by line even if no such DB exists.
CREATE DATABASE Human
USE Human
CREATE TABLE People
(
Id INT PRIMARY KEY,
[Name] NVARCHAR(200) NOT NULL,
Picture VARBINARY(MAX),
Height DECIMAL(5,2),
[Weight] DECIMAL(5,2),
Gender BIT NOT NULL,
Birthdate DATETIME NOT NULL,
Biography NVARCHAR(MAX)
)
INSERT INTO People(Id, [Name], Picture, Height, [Weight], Gender, Birthdate, Biography) VALUES
(1, 'Tony', NULL ,1.81, 65.43, 0, '1957-05-10', NULL),
(2, 'Mark', NULL ,1.81, 65.43, 0, '1957-05-10', NULL),
(3, 'Tanya', 5 ,1.81, 65.43, 1, '1957-05-10', NULL),
(4, 'Марк', NULL ,1.81, 65.43, 0, '1957-05-10','Dura bura'),
(5, 'Toncho', 2 ,1.81, 65.43, 0, '1957-05-10','Сто чадъра')
Upvotes: 0
Reputation: 713
Are you experiencing this problem with provided statement/data or is the statment/data an example and not 1:1?
Som maybe some DB/sErver setting that i cant think of of my head.
is this the exact data you get the error on? my guess would be you have a numeric value for height or weight thats more then 999.99. Maybe missing decimal dot for weight?
Upvotes: 1