continue running job if error occur

  • 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

  • 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.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hi,

    try an catch is the only way to allow the proc to continue to run even if he have an error?

    THX

  • 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...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • 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