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 Help

Author  Topic 

humanpuck
Yak Posting Veteran

94 Posts

Posted - 2006-07-21 : 09:17:59
Hi Folks,

Is there any way in DTS to automatically delete the source file once you've finished importing it. Or is this something thats beyond what can be done with DTS.

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-21 : 09:29:56
You can create another task to do the delete following the imnport task. It would be an os command.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

humanpuck
Yak Posting Veteran

94 Posts

Posted - 2006-07-21 : 09:47:08
Would I have to register a custom task or is executing an OS command already a task. Only reason I ask is that I don't see it as a registered task.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-21 : 10:22:57
Do you see an execute process task? you can put the delete in a .bat file.

You can also use an activex task

' Delete File
Option Explicit


Function Main()

Dim oFSO
Dim sSourceFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSourceFile = "C:\myfile.txt"
oFSO.DeleteFile sSourceFile
Set oFSO = Nothing
Main = DTSTaskExecResult_Success
End Function


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

humanpuck
Yak Posting Veteran

94 Posts

Posted - 2006-07-21 : 10:58:51
Thanks for the help NR...I appreciate it.
Go to Top of Page

humanpuck
Yak Posting Veteran

94 Posts

Posted - 2006-07-21 : 14:23:14
Is there a way to Rename this file instead of deleting it? Instead of a DeleteFile is there a RenameFile? I suck at VB Scripting.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-21 : 14:28:51
quote:
Originally posted by humanpuck

Is there a way to Rename this file instead of deleting it? Instead of a DeleteFile is there a RenameFile? I suck at VB Scripting.



You can do it with VBScript or you could use DOS commands. Through DOS, I believe you move the file to the new name, then delete the old. There might be a quicker way though, but this is what I recall doing in the past. Run help /? from a cmd window to see what your options are.

Tara Kizer
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-07-22 : 10:28:51
The move renames the file.
With a copy you would delete the old.

With the FSO script it would be
Set oFile = oFSO.GetFile("c:\myfile.txt")
oFile.Move "c:\myfile2.txt"


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -