Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bypassign error

Status
Not open for further replies.

camy123

Programmer
Mar 5, 2004
171
GB
guys need your help please
I have a store procedure runnign via scheduler and sql agent keeps aborting it when it comes to a certain error what i need is to nto allow the script to be aborted even tho there is a error there ne ideas
Please
 
What is the full error? Any error of level 16 and above will automatically stop the batch.

--James
 
Im not sure of the error to hand but does that mean theres no way to trap the error and allow the script to carry on...if @@error > 16
 
What you can do is put the code that you want to check inside a stored proc. Then check the return value from that:

Code:
CREATE PROC invalid
AS

--error - divide by zero
SELECT 1/0
GO

Code:
DECLARE @ret int

EXEC @ret = invalid
IF @ret <> 0
	PRINT 'An error occured in the SP'
ELSE
	PRINT 'All ok'

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top