Server Agent Job Step

  • Hi there!

    I had created one job, & three steps in this job. Now I want to go to step no. 2 only when following condition is satisfied: 

    if (select count(*) from tnp where tnpdate=GetDate()) > 0

    SO, if count comes > 0, then I want to execute something(may be query/stored proc/command) here so that it should be in step no. 1 only...I don't want it to switch to step no. 2.

    Else it should go to step no. 2.

    So what do I do?

    Plz help...it's urgent.

    Thanks.

    Gaurav

  • I think if you include something like :

    if not ((select count(*) from tnp where tnpdate=GetDate()) > 0)

    raiserror('Count condition was not met.', 15,1)

     

    --

    ..., enable retries on that step, and set the 'on failure' action to 'go to the next step'  (these are all options that are available in the advanced tab on the step properties)

    you might want to use a different error/severity level for the raiserror statement, but it's only for design style, this combination should work

     

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

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