HNA071252
asked on
sql server 2005
Why am I getting this error?
I have a store procedure that it's been working, suddenly i'm getting this error and have no idea why.
Arithmetic overflow error converting expression to data type tinyint.
I have a store procedure that it's been working, suddenly i'm getting this error and have no idea why.
Arithmetic overflow error converting expression to data type tinyint.
ASKER
i'm using sql server 2005.
And the code is in this block:
UPDATE BsYr SET PlnUpdated = 1,
PlnIP = PlnIP/(CASE [cntContr]
WHEN 1 THEN ((Mn1 - 1) + ((13 - Mn1) * (1 + Mn1IP)))
WHEN 2 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1IP)) + ((13 - Mn2) * (1 + Mn2IP)))
WHEN 3 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1IP)) + ((Mn3 - Mn2) * (1 + Mn2IP) * (1 + Mn1IP)) +
((13 - Mn3) * (1 + Mn3IP) * (1 + Mn2IP) * (1 + Mn1IP))) END),
PlnOP = PlnOP/(CASE [cntContr]
WHEN 1 THEN ((Mn1 - 1) + ((13 - Mn1) * (1 + Mn1OP)))
WHEN 2 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1OP)) + ((13 - Mn2) * (1 + Mn2OP)))
WHEN 3 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1OP)) + ((Mn3 - Mn2) * (1 + Mn2OP) * (1 + Mn1OP)) +
((13 - Mn3) * (1 + Mn3OP) * (1 + Mn2OP) * (1 + Mn1OP))) END),
PlnTot = PlnTot/(CASE [cntContr]
WHEN 1 THEN ((Mn1 - 1) + ((13 - Mn1) * (1 + Mn1Tot)))
WHEN 2 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1Tot)) + ((13 - Mn2) * (1 + Mn2Tot)))
WHEN 3 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1Tot)) + ((Mn3 - Mn2) * (1 + Mn2Tot) * (1 + Mn1Tot)) +
((13 - Mn3) * (1 + Mn3Tot) * (1 + Mn2Tot) * (1 + Mn1Tot))) END)
FROM TRP.FFS_Data_ProjBase BsYr INNER JOIN TRP.FFS_Data_ProjBase_Calc calc ON
BsYr.Parent_Id_sfx = calc.ParentTIN AND
BsYr.FFS_Contract = calc.TypeOfContract
And the code is in this block:
UPDATE BsYr SET PlnUpdated = 1,
PlnIP = PlnIP/(CASE [cntContr]
WHEN 1 THEN ((Mn1 - 1) + ((13 - Mn1) * (1 + Mn1IP)))
WHEN 2 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1IP)) + ((13 - Mn2) * (1 + Mn2IP)))
WHEN 3 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1IP)) + ((Mn3 - Mn2) * (1 + Mn2IP) * (1 + Mn1IP)) +
((13 - Mn3) * (1 + Mn3IP) * (1 + Mn2IP) * (1 + Mn1IP))) END),
PlnOP = PlnOP/(CASE [cntContr]
WHEN 1 THEN ((Mn1 - 1) + ((13 - Mn1) * (1 + Mn1OP)))
WHEN 2 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1OP)) + ((13 - Mn2) * (1 + Mn2OP)))
WHEN 3 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1OP)) + ((Mn3 - Mn2) * (1 + Mn2OP) * (1 + Mn1OP)) +
((13 - Mn3) * (1 + Mn3OP) * (1 + Mn2OP) * (1 + Mn1OP))) END),
PlnTot = PlnTot/(CASE [cntContr]
WHEN 1 THEN ((Mn1 - 1) + ((13 - Mn1) * (1 + Mn1Tot)))
WHEN 2 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1Tot)) + ((13 - Mn2) * (1 + Mn2Tot)))
WHEN 3 THEN ((Mn1 - 1) + ((Mn2 - Mn1) * (1 + Mn1Tot)) + ((Mn3 - Mn2) * (1 + Mn2Tot) * (1 + Mn1Tot)) +
((13 - Mn3) * (1 + Mn3Tot) * (1 + Mn2Tot) * (1 + Mn1Tot))) END)
FROM TRP.FFS_Data_ProjBase BsYr INNER JOIN TRP.FFS_Data_ProjBase_Calc
BsYr.Parent_Id_sfx = calc.ParentTIN AND
BsYr.FFS_Contract = calc.TypeOfContract
So, check the datatypes of the various columns involve and set up a SELECT statement that will "select" the values you are trying to update the tinyint columns too. When you execute the SELECT statement, it should show you which of the tinyint columns you are overflowing.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
UPDATE BsYr SET PlnUpdated = 1
FROM TRP.FFS_Data_ProjBase BsYr INNER JOIN TRP.FFS_Data_ProjBase_Calc calc ON
BsYr.Parent_Id_sfx = calc.ParentTIN AND
BsYr.FFS_Contract = calc.TypeOfContract
This one alone run fine. And in this table only PlnUpdated has tinyint and the rest of the columns (PlnIP, PlnOP, PlnTot) has float.
FROM TRP.FFS_Data_ProjBase BsYr INNER JOIN TRP.FFS_Data_ProjBase_Calc
BsYr.Parent_Id_sfx = calc.ParentTIN AND
BsYr.FFS_Contract = calc.TypeOfContract
This one alone run fine. And in this table only PlnUpdated has tinyint and the rest of the columns (PlnIP, PlnOP, PlnTot) has float.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
in your sp, you are trying to cast/convert/assign a big integer to tinyint... post the code, or find the varieble which is defined as tinyint and make it int or bigint