importing files using dts
- From: "chinna jambu via SQLMonster.com" <forum@xxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Apr 2005 01:58:02 GMT
Hi
I am using looping,importing and archieving example for importing multiple
files into sql server database.
here is my code
create table -----> Active x Script 1 -------> Text File Source ------>
transformation task -----> Active x script 2
Active X script 1
*********************
Option Explicit
Function Main()
dim pkg
dim conTextFile
dim stpEnterLoop
dim stpFinished
set pkg = DTSGlobalVariables.Parent
set stpEnterLoop = pkg.Steps("DTSStep_DTSDataPumpTask_1")
set conTextFile = pkg.Connections("Text File (Source)")
if ShouldILoop = True then
stpEnterLoop.DisableStep = false
conTextFile.DataSource = DTSGlobalVariables("Filename").Value
stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting
End if
Main = DTSTaskExecResult_Success
End Function
Function ShouldILoop
dim fso
dim fil
dim fold
dim pkg
dim counter
set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fold = fso.GetFolder(DTSGlobalVariables("Folder").Value)
counter = fold.files.count
if counter >= 1 then
for each fil in fold.Files
DTSGlobalVariables("Filename").Vmsgbox fil.path
ShouldILoop = CBool(True)
Next
End if
End Function
Active x script 2
***********************
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
Dim pkg
Dim stpBegin
dim fso
dim fil
dim fold
set pkg = DTSGlobalVariables.Parent
msgbox "suchi"
set stdBegin = pkg.Steps("DTSStep_DTSActiveScriptTask_1")
set fso = Createobject("Scripting.FileSystemObject")
stdBegin.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
End Function
the loop is going through the files in the directory, but the last file
data is only loaded into the temp table.
Can any suggest me a solution for my problem.
thanks
--
Message posted via http://www.sqlmonster.com
.
- Follow-Ups:
- Re: importing files using dts
- From: Allan Mitchell
- Re: importing files using dts
- Prev by Date: Type Mismatch: DTSLookups?
- Next by Date: Re: importing files using dts
- Previous by thread: Type Mismatch: DTSLookups?
- Next by thread: Re: importing files using dts
- Index(es):
Relevant Pages
|