Pass Exit code from SQL Job Step

  • I want to run a test on a certain table to see if a value exists:

    IF EXISTS

    ((SELECT 1 FROM MTDC_ADMIN..DBAvailabilityAlert

    WHERE InstanceName like @instancename AND FailedFlag like 'F') >=1)

    IF the value is 1 as above, I want the job step to end with Success

    IF the value is anything other than 1 I want the job step to end with Failure.

    Then I can point the job toward the next appropriate step.

    Unfortunately the job reports success no matter what the value.

    Is there any way to pass an exit code to SQL Server?

    FWoolverton

  • Just use RAISERROR in the second case. This is going to force the Scheduler to end the step with a failure.

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

Viewing 2 posts - 1 through 1 (of 1 total)

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