ideasworking
Programmer
Hello,
I could use some help identifying a problem with my stored procedure. This stored procedure subtracts the values from two tables and updates a third table with the result.... er well, that's the way I want it to work.
All three tables have datatype numeric (18,1). The value in tempToday is 888932.1 and the value in tempYesterday is 864408.4
When I execute the code I get the error "Arithmetic overflow error converting varchar to data type numeric."
The SP works if I change the string @UpdateSQL to
Here's the section of the SP that I'm working on.
Thanks for the help,
Lou
I could use some help identifying a problem with my stored procedure. This stored procedure subtracts the values from two tables and updates a third table with the result.... er well, that's the way I want it to work.
All three tables have datatype numeric (18,1). The value in tempToday is 888932.1 and the value in tempYesterday is 864408.4
When I execute the code I get the error "Arithmetic overflow error converting varchar to data type numeric."
The SP works if I change the string @UpdateSQL to
Code:
@UpdateSQL = 'UPDATE [Reporting].[dbo].[DailyTotals] SET [1010Gas] = 24523.7 WHERE [DateAndTime] = ''' + CONVERT(CHAR(10), @TenYesterday, 120) + ''''
Here's the section of the SP that I'm working on.
Thanks for the help,
Lou
Code:
Select @GasUsed =
Case when SUM(CASE WHEN tempToday.TagName = 'SERVER01.FI1005T_TOT.F_CV' THEN tempToday.Value-COALESCE(tempYesterday.Value,0) ELSE 0 END) < 0 then
SUM(CASE WHEN tempToday.TagName = 'SERVER01.FI1005T_TOT.F_CV' THEN tempToday.Value-COALESCE(tempYesterday.Value,0)ELSE 0 END) +1000000
else
SUM(CASE WHEN tempToday.TagName = 'SERVER01.FI1005T_TOT.F_CV' THEN tempToday.Value-COALESCE(tempYesterday.Value,0)ELSE 0 END)
end
FROM tempYesterday
LEFT JOIN tempToday ON tempyesterday.TagName = tempToday.TagName
declare @UpdateSQL varchar(4000)
select @UpdateSQL = 'UPDATE [Reporting].[dbo].[DailyTotals] SET [1010Gas] = ''' + @GasUsed + ''' WHERE [DateAndTime] = ''' + CONVERT(CHAR(10), @TenYesterday, 120) + ''''
exec (@UpdateSQL)