Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 DTS Import Empty or non-existing file

Author  Topic 

bp999947
Starting Member

1 Post

Posted - 2005-02-14 : 14:39:56
I have a process that I am trying to get to work in DTS. There are 3 files that have to be imported before a SQL task is kicked off. It is valid for any or all of the 3 input files to be empty, but if there is data in any of them, it needs to be imported before the SQL task runs.

The following code keeps the process from erroring if the file is empty or does not exist, but returns a "Not Run" status when the package is executed. How can I get the SQL task to run, but only after all 3 input files have either been imported, or have nothing to import and return a 'not run'?

Thanks in advance.

Function Main()
Dim fso
Dim f
Dim FileName

' file to check for a zero-byte length
FileName = "\\server1\test\Recs1.Txt"

Set fso = CreateObject("Scripting.FileSystemObject")

IF fso.FileExists(sFilename) Then
Set f = fso.GetFile(FileName)

IF f.Size = 0 Then
Main = DTSStepScriptResult_DontExecuteTask
ELSE
Main = DTSStepScriptResult_ExecuteTask
END IF
ELSE
Main = DTSStepScriptResult_DontExecuteTask
END IF

Set f = Nothing
Set fso = Nothing
End Function
   

- Advertisement -