ActiveX job step in SQL Server Agent

  • I am wanting to preven my job from failing if a file not exist; it's kind of backwards and I'm new at this.  The ActiveX script works in a DTS package to fail the step; when I use it as a step in a "job" it's not working like I want.

    This is the log I get for the job: The step did not generate any output.  The step succeeded.  The job is only two steps and I need it to start withe ActiveX as the first step to check file.  I think it has something to do with the result syntax.  Please help.  Thanks.

    Function Main()

     sFile = " C:\test.txt"

     

     Set oFSO = CreateObject ("Scripting.FileSystemObject")

     If oFSO.FileExists (sFile) Then

      

      Main = DTSTaskExecResult_Success

     Else

      

      

      Main = DTSTaskExecResult_Failure

     End If 

     

     Set oFSO = Nothing

     

    End Function

  • If you don't want your job to report a failure then you will need to remove the

    Main = DTSTaskExecResult_Failure

    You might want to create an empty (null) file and have the DTS package "process" that if the test.txt does not exist.

    -------------------------------------------------------------------------
    Normal chaos will be resumed as soon as possible. :crazy:

  • I thought of a few work arounds, I could make an extra pkg just for the file check to on fail quit with success but didn't want to packages for every package or even extra steps in the job.  This is seeming to work now with adding a workflow property to prevent the dts package step from failing and the job has'nt reported a failure either:

     

    Function Main()

     sFile = "C:\any.txt"

               

                Set oFSO = CreateObject ("Scripting.FileSystemObject")

                If oFSO.FileExists (sFile) Then

                            Main = DTSStepScriptResult_ExecuteTask

                Else

                            Main = DTSStepScriptResult_DontExecuteTask

                End If   

    End Function

     

    Since this step is the first in the package It can't fail if the file is not there, there is possibly a Main = "something to say job success or job failure" results statement when using ActiveX as a job step that would give the output needed. 

    Thanks.

     

    Moderator, as a newbie how can this thread be closed?

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

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