Dts import -
02-11-2005
, 02:54 PM
I have 10 csv files with different names in c:\mydirectory\.
I created global variable "ImportFolder" which has value "c:\mydirectory\
LDP_*.csv"
files names are
LDP_aaa.csv,
Ldp_bbb.csv,
LDP_ccc.csv
ADP_aaa.csv,
ADp_bbb.csv,
ADp_cc.csv. ....
My question here is i want to import only All LDP_*.csv to sql server table
and ignore ADP_*.csv files from the directory in sequence.
Here is the code i used to get first file from directory.
Function Main()
Dim sFolder
Dim fso
Dim fsoFolder
Dim fsoFile
Dim sFilename
sFolder = DTSGlobalVariables("ImportFolder")
set fso = CreateObject("Scripting.FileSystemObject")
set fsoFolder = fso.GetFolder(sFolder)
For Each fsoFile in fsoFolder.Files
sFilename = sFolder & fsoFile.Name
if left (sFilename,20) = "//cpmqsit\mssql7\ldp" then
Exit For
end if
Next
Dim oPKG
Dim oConnection
Dim stdEnterLoop
set oPKG = DTSGlobalVariables.Parent
set oConnection = oPKG.Connections ("Text File (Source)")
oConnection.DataSource = sFilename
Main = DTSTaskExecResult_Success
End Function
because of this statement For Each fsoFile in fsoFolder.Files , all files
are loaded in to the table.
please reply me as soon as possible Urgent.
thanks
--
Message posted via http://www.sqlmonster.com |