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)
 Need help on handling file name

Author  Topic 

azhu
Starting Member

3 Posts

Posted - 2004-03-30 : 23:41:31
Hi,

I am doing a job using DTS to upload billing data. The data provider runs a mainframe and FTP to us irregularly (not every day) a UNIX gzipped file. I intend to set up a daily job to check the upload directory to see if there is new files there if yes, then read the file name in order to process it.

I think this can be done using a VB script, but how?

Thanks

Arthur

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-03-31 : 00:23:46
Yes it can be definately be done with vbscript.
Read up on the FileSystemObject in msdn, you will be able to achieve this using some of the properties and methods associated with it.



Duane.
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-03-31 : 00:36:22
An example of such code might look something like this:

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()


FilePath = "\\ServerName\PathName\FileName.txt"

MaxDiff = 0

Set fso = CreateObject("Scripting.FileSystemObject")
Set Flash = fso.GetFile(FilePath)
FileDatetime = Flash.DateLastModified

TimeDiff = DateDiff("d", Flash.DateLastModified, Now)

'Clear memory space the objects occupy:
Set fso = Nothing
Set Flash = Nothing

If TimeDiff > MaxDiff Then
DTSGlobalVariables("ErrorMessage").Value = "LOAD STOPPED! file too old: It arrived at " & FileDatetime
Main = DTSTaskExecResult_Failure
Else
Main = DTSTaskExecResult_Success
End If

End Function


Duane.
Go to Top of Page
   

- Advertisement -