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 Script - retrieve first file in directort only

Author  Topic 

MarkyBoy666
Starting Member

14 Posts

Posted - 2005-02-10 : 11:30:56
Hello,

I'm new to DTS and was wondering if anyone could help me with this.

I'm wanting to perform a variation on the code:

For Each fsoFile In fsoFolder.Files


which would normally loop through all files in a folder...but what I'm wanting to do instead is to modify this to only return the FIRST file in the folder (any file, it doesn't really matter which). Sort of something like...

For FIRST fsoFile In fsoFolder.Files


Does anyone know what the syntax I'm looking for is?

Many, many thanks indeed.

Maquis
Starting Member

25 Posts

Posted - 2005-03-03 : 11:13:48
How about this? You would exit the for loop after the first time, with the filename saved in a variable name and/or global variable...

For Each fsoFile in fsoFolder.Files
sSourceFile = fsoFile.Name
DTSGlobalVariables("filename").Value = fsoFile.Name
exit for
Next
Go to Top of Page
   

- Advertisement -