File exists via xp_fileexist and ActiveX

  • Hello all,

    Maybe you can help me out.

    I am trying to build a DTS using an Execute SQL Task and an ActiveX Script Task.

    The Execute SQL Task looks  like this:

    declare @out int

    exec master..xp_fileexist '\\serverA\c$\Import\fileA.txt', @out output

    select STR(@out) as f_exists

    I have mapped the column f_exists as a row value to a global variabele FileExist; this global variabele is tested in the ActiveX script:

             Dim oGlobalVariable

             For Each oGlobalVariable In DTSGlobalVariables

                     MsgBox oGlobalVariable.Name

                     MsgBox oGlobalVariable.Value

             Next

             Main = DTSTaskExecResult_Success

    The ActiveX script is run on success of the Exexute SQL Task.

    When I run this DTS the result for oGlobalVariable.Value is not updated with the value that is found in the SQL Task (so when the file is there, I still get a 0 as result, while it should be a 1).

    When I run the Execute SQL Task code in Query Analyser, result is 1 (so: file is present).

    What could be the case here? Why is the global variable not filled with the output of the SQL code? I checked the parameter mapping and that was ok.

    Thanx.

    Hans

  • I've got this covered already; it seems that the global variabele only is filled after a select from a table, and not when used directly as the result of the xp_fileexist procedure.

    All in all a pretty elaborate way just to check if a file is present.

    Hans

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

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