Cursor works fine - doesn't from job?

  • The main goal of this process is to hop through different servers and databases and execute this query. I have attached my script, my script works when i run through management studio and gives me the list of servers/dbs where it failed..great..but when i run through the job in the job history and the log which i have set on the step doesn't give me the same information. My goal is to get entire out whatever i see when i run from management studio to be written in the output file. Would be great if someone can assist me.Thanks in advance.

  • It depends where you want to see the output of the job.

    Here are some options (most probably there are several more...):

    1) create a table to hold the error messages and the related job information (start time or the like)

    2) collect the messages in a variable and send an email at the end of the job

    3) use RAISERROR or xp_logevent to write the messages to SQL Server log file and in the Windows Event Viewer.



    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]

  • Thanks, but this only solves part of the problem, as i mentioned in the post if i ran the exact sql in attachment runs fine but when i run through a job stops wherever it fails doesn't go to the next server/db..also i want to capture the exact log what i see from management studio..

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

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