VB Script in a Job

  • I have placed a VB script in a job and was curious on what I can use to return a value to the job to let it know if it was successful or not.

    To test out the features I added a script that looks for a file, and if found msgbox back found, but it seems the Job functionality is not dynamic to the client to give a return. Any thoughts. -Jay


    -JG

  • What type of client? Is this a T-SQL that calls sp_start_job?

    Is it DMO?

    Steve Jones

    steve@dkranch.net

  • I embedded the code in the Enterprise Manager>>Management>>SQL Server Agent>> Jobs.

    In the graphical tool I added a step and choose ActiveX Script in step type, and the radio btn VB.

    I am using SQ 7.0 I am running the client utilities on Win2K.


    -JG

  • The only way I've seen is to use the 'print' statement in the script - it will write out whatever you 'print' to the job history. Useful, sorta. If you want to pass a parameter, use a table or a file that you reference in the previous/next step. Avoid msgbox in script - you can wind up with a job that is hung up - the message box will pop but it is hidden, no way to click it.

    Andy

  • I agree with Andy, use a table or other more permanent reference point.

    Steve Jones

    steve@dkranch.net

  • I am trying to get the Job to error out if the file is not present. Then I can attempt the retry in the advance tab. I Used Print, but the job simply succeeded.


    -JG

  • You can fail the package and this will a failed job message to the sqljob.

    In the ActiveX script, there has to be a setting to mark the script as failed. There are a couple options in the DMO section. Perhpas try one of those.

    Steve Jones

    steve@dkranch.net

Viewing 7 posts - 1 through 6 (of 6 total)

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