how to raise an error without job step failing ?

  • HI,

    I have a job step, whick checks for record count and if it is equal to 0, then we have raiserror. IF not it goes to nest step and executes an exe.

    Step 1:

    DECLARE @Count int

    Select @Count = Count(ColID) from Table1

    WHERE ColFlag = 1

    if (@Count = 0)

    RAISERROR('No Active Request', 15,1)

    Step2 : Calls an exe.

    As I said, we want to execute step 2, only when there is a records in Table1 with the ColFlag1 = 1, other wise just quit the job.

    Any other alternative way of doing this ? I had set the On success: go to next step and on failure: quit the job reporting success. But still the job has a warning sign and the step failed with big red mark :-(.

    Thanks,

    VG

  • I would add another statement to reset the errorlevel. a

    select 1

    ought to do it.

  • Sorry, I didn't get it...Where to set the errorlevel ?

    Thanks Steve!!

  • I would suggest as follows:

    DECLARE @Count int

    Select @Count = Count(ColID) from Table1 WHERE ColFlag = 1

    if (@Count > 0)

    Calls an exe.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply