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)
 While in a loop execute another task

Author  Topic 

Yukon2005
Starting Member

8 Posts

Posted - 2006-03-29 : 06:36:26
Hi peeps,

I currently have a ActiveX Script Task(vbscript) that loops through a specific directory and returns all the files in that directory. The Filename is assigned to a global variable. Now everytime a filename is returned it should insert it into the "mytable" table in the database. How do I do this??? Here is my current code...

Function Main()
dim oFileName oFileName = "C:\Program Files\" dim oFso set oFso = CreateObject("Scripting.FileSystemObject")
dim oFolder set oFolder = oFso.GetFolder(oFileName)
dim oFile for each oFile in oFolder.Files
'Wscript.Echo "File Name: " & oFile.path

'populate variable
DTSGlobalVariables("gvFileFullName").Value = oFile.path

'execute a different task to insert data into a table
'insert into mytable (FullPathName) values (DTSGlobalVariables("gvFileFullName").Value)
next

'wscript.echo "Completed"
'continue with package
Main = DTSTaskExecResult_Success
End Function

Should I create a a sql task with syntax:

insert into mytable (FullPathName) values (?)

then assign the value of the gvFileFullName global variable to "?", but to I execute this task again? Once the loop has completed I would like to continue to the next step in the dts package.

Thanks in advance guys...

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2006-03-29 : 10:37:21
I'm sure you can create a T-SQL statement to pipe the output of a "DIR" statement executed via xp_cmdshell into a table for onward processing. Search member 'nr's website for some useful snippets in this arena.
Go to Top of Page
   

- Advertisement -