Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if file exits before running DTS

Status
Not open for further replies.

yanios

MIS
Jun 9, 2004
28
0
0
US
Any help is appreciated.
How can use SQL to I test to see if the new text file exits before running a scheduled DTS import? If the new file is not there, the DTS import does not to run.
Must I run test thru DOS first? Don't have a clue.
Thank you.
 
You can use an ActiveX script in DTS that uses FSO (File System Object). I use this as an initial step for most of my packages to verify that the file exists first.

Ex:

Code:
Function Main()

Dim objFSO
Dim cFilePath
Dim cFileName

cFilePath = "<file path>"
cFileName = "<file name>"
 
  ' instantiate the Scripting Object
  set objFSO = CreateObject("Scripting.FileSystemObject")

  With objFSO
    If .FileExists(cFilePath & cFileName) Then
       ' set on Global Variable that file exists..
    End if
  End With
  Set objFSO = Nothing
  Main = DTSTaskExecResult_Success
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top