February 28, 2010 at 3:21 pm
Hi,
i write a proc that use cursor to backup my databases.
when i deliberately make an error in the proc for lets say that i try to make transaction log backup when this database never get full backup before i get an error this is ok when the proc run in the query analyzer it continue to run even if the proc have error and it finish the proc and report the error.
but when i put the proc inside sql agent job the proc stop running after he get the first error.
how i can force the proc to continue to run inside sql agent job even if the proc have error and report the error in the end?
THX
February 28, 2010 at 4:46 pm
Did you try to wrap your code into TRY ... CATCH blocks?
That would give you the option to control the "behavior" of a proc.
If you want to control more than one block, you'd need to use more than one TRY ... CATCH blocks.
March 1, 2010 at 12:53 am
Hi,
try an catch is the only way to allow the proc to continue to run even if he have an error?
THX
March 1, 2010 at 10:01 am
Mad-Dog (3/1/2010)
Hi,try an catch is the only way to allow the proc to continue to run even if he have an error?
THX
Well, you could setup each step of your proc as a separate proc and run it one after the other within your job and defiine "On failure action" as "Go to the next step".
However, I wouldn't use that option...
March 1, 2010 at 10:20 am
THX.
i'll go with the try an catch.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply