cannot attach the output of the job step

  • Hello folks,

    I am looking for ideas or if anyone experienced the same before.

    I have 1 step SQL Server 2012 job.

    So it executes the Stored Proc with some convoluted logic and it outputs it to the text file(from Advanced->Output File)

    If execution of the Stored Proc fails, the Stored proc is trying to send an email attaching the output file.

    It cannot send it, because the output file is locked until the Step 1 (as well as Job) completes.

    Creating Step 2 for failure notification, where I can send output file as an attachment won`t work for me because I will need to duplicate the half of the logic of the Stored Proc I use in step 1. Which doesn't make any sense.

    Any other ideas on how to email the output of the job step-Stored Proc execution in one shot.

    Thank you all

  • inHouseDBA (4/24/2016)


    Hello folks,

    I am looking for ideas or if anyone experienced the same before.

    I have 1 step SQL Server 2012 job.

    So it executes the Stored Proc with some convoluted logic and it outputs it to the text file(from Advanced->Output File)

    If execution of the Stored Proc fails, the Stored proc is trying to send an email attaching the output file.

    It cannot send it, because the output file is locked until the Step 1 (as well as Job) completes.

    Creating Step 2 for failure notification, where I can send output file as an attachment won`t work for me because I will need to duplicate the half of the logic of the Stored Proc I use in step 1. Which doesn't make any sense.

    Any other ideas on how to email the output of the job step-Stored Proc execution in one shot.

    Thank you all

    I might be missing something but why wouldn't you just make Step 1 branch to Step 2 if there was a failure and branch to Step 3 if there was no failure? It's pretty easy to do with the "On Success" and "On Failure" settings for each step.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Actually thanks for reply, Jeff. As your reply helped me found a bug.

    I need to revisit my code again.

  • Can you send me few links, if any, on how to output the execution of stored proc to the text file?

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

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