Re: make a job successful



BTW, I used the same logic as your original script but it seems to me to be reversed. I think it should be:

If oFSO.FileExists(sFilename) Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Dan Guzman" <guzmanda@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:7F7312FD-2D2F-487E-944D-8F6558F0233B@xxxxxxxxxxxxxxxx
How can I make a job successful when it contains a DTS package that transfers data from a text file to a SQL Server table and updates the table? The problem is the job should run daily but the file may not always be there


One method is to control the workflow with an ActiveX script. Right-click on your transform data task and select workflow properties-->options-->use ActiveX script-->Properties. Paste a script like your original but with a DTSStepScriptResult value indicating whether or not the the task (and subsequent tasks in the workflow) should be executed. You might also consider adding a text annotation to the package to document the that a workflow ActiveX script property is set.

Function Main()

Dim oFSO, sFileName

sFilename = DTSGlobalVariables.Parent.Connections("File2").DataSource

Set oFSO = CreateObject("Scripting.FileSystemObject")

' Check for file and return appropriate result

If oFSO.FileExists(sFilename) Then

Main = DTSStepScriptResult_DontExecuteTask

Else

Main = DTSStepScriptResult_ExecuteTask

End If

Set oFSO = Nothing

End Function


--
Hope this helps.

Dan Guzman
SQL Server MVP

"Lhoussain" <lhoussain@xxxxxxxxxx> wrote in message news:46e90dd9$0$31864$426a74cc@xxxxxxxxxxxxxxx
How can I make a job successful when it contains a DTS package that transfers data from a text file to a SQL Server table and updates the table? The problem is the job should run daily but the file may not always be there :

Function Main()

Dim oFSO, sFileName



sFilename = DTSGlobalVariables.Parent.Connections("File2").DataSource



Set oFSO = CreateObject("Scripting.FileSystemObject")



' Check for file and return appropriate result

If oFSO.FileExists(sFilename) Then

Main = DTSTaskExecResult_Failure

Else

Main = DTSTaskExecResult_Success

End If



Set oFSO = Nothing

End Function





Thank's



Djam




.



Relevant Pages

  • Re: make a job successful
    ... transfers data from a text file to a SQL Server table and updates the table? ... Dim oFSO, sFileName ... Set oFSO = CreateObject ...
    (microsoft.public.sqlserver.dts)
  • Re: Error 15401 using sp_grantlogin (not addressed by current KB articles)
    ... Restarting Windows 2000 resolved the problem for this particular account, ... confused when it sees a duplicate SID. ... > One way to get SQL Server to agree with the renamed NT ... > Preview (to ensure the script was created), ...
    (microsoft.public.sqlserver.security)
  • Re: Scripting a SQL database
    ... Virtually everything SQL Server Enterprise Manager does can be ... To run the generated script in ASP, ... You can also create a DTS (Data Transformation Package) ... that you'll want to select the "copy database objects and data" ...
    (microsoft.public.inetserver.asp.db)
  • Re: SQL Security
    ... except I'm having problems making it work in a script. ... ;Set properties of DB objects and open connection to database ... > from Books Online (within the SQL Server program group): ... > communicate with SQL Server. ...
    (microsoft.public.sqlserver.server)
  • Re: Scripting a SQL database
    ... Virtually everything SQL Server Enterprise Manager does can be ... To run the generated script in ASP, ... You can also create a DTS (Data Transformation Package) ... that you'll want to select the "copy database objects and data" ...
    (microsoft.public.sqlserver.server)