April 9, 2004 at 8:01 am
Hi all!
I need some help with DTS package importing a text file. I am importing a text file into a table using the DTS package that runs a job to import this txt file every day at a certain time. I want to be able to delete this txt file after the import is complete. How do I do this? Any help is greatly appreciated.
Thanks in Advance!
SD
April 9, 2004 at 9:25 am
Hi There,
Use the file scripting object in an ActiveX Task to delete your file after your import step is successful.
Function Main()
dim oFSO
' instantiate the Scripting Object
set oFSO = CreateObject("Scripting.FileSystemObject")
' Delete the file
oFSO.DeleteFile("C:\yourfilename.txt")
Main = DTSTaskExecResult_Success
End Function
HTH
April 9, 2004 at 11:12 am
Thanks for your help! I really appreciate it.
SD
April 9, 2004 at 2:15 pm
When I tried to save the script, it is giving an error. It says that the job was not saved because all objects that were created were not destroyed. The error code is 14277. I added a line that said oFSO.close, but that did not help.
Thanks again,
Shree
April 9, 2004 at 2:47 pm
Hey,
Never mind! I just found out I needed to set the object to Nothing
set oFSO = Nothing
That worked!
Thanks!
SD
April 10, 2004 at 1:11 pm
oops! Sorry, forgot that bit !! Always good practice to destroy the object when done.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply