Link to home
Start Free TrialLog in
Avatar of davidcahan
davidcahanFlag for United States of America

asked on

Arithmetic Overflow Not Causing Job to Fail

I have a job.  Step 1 of the job looks like this:

declare @sql varchar(8000)
select @sql = 'bcp "exec FOOBAR.dbo.ExportDNCToSpectrum" queryout c:\inetpub\ftproot\DNC\CoDNCForRiseFS02.csv -c -t, -T -S'+ @@servername

exec master..xp_cmdshell @sql

the SP "ExportDNCToSpectrum" is suddenly raising an arithmetic overflow error, however this isn't causing the job to fail.  So basically I had no idea for weeks that anything was wrong.  I've tried adding Set ANSI_WARNINGS ON in both the SP and the job step but to no avail.  What gives.  What am i doing wrong.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>exec FOOBAR.dbo.ExportDNCToSpectrum
that is a stored procedure, right?
your @sql will only return the LAST error that occured in the procedure, not "any" or the "first".
so, if there are some statement after that failing in the procedure, your procedure returns no error(s) ...

you need to hande errors in your stored procedure
Avatar of davidcahan

ASKER

i know what you are saying but not clear on how to implement and have the error bubble up and cause the job to fail.  could you provide me a simple example of how I would handle the error in the SP given the circumstances I outlined.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
great...thanks for the quick and precise feedback!!!
as usual with AngelIII, the feedback was quick and right to the point with links  to documentation for each item.