How can I have a DTS package rename a file?
for example, I have a file c:\temp.txt
I would like to have a DTS package change it to c:\temp060806.txt (the
numbers is teh date)
ThanksYou need an ActiveX script task in your DTS package to do this. In your
ActiveX script task, you have to instantiate the FileSystemObject object to
rename the file.
Here's an example from one of my DTS packages:
dim DataFile, FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
DataFile = DTSGlobalVariables("FileLocation")
If FSO.FileExists(DataFile) Then
FSO.MoveFile DataFile, DTSGlobalVariables("ProcessedFiles") + "Orders_"
+CStr(Year(Now)) + Right("0" + CStr(Month(Now)), 2) + Right("0" +
CStr(Day(Now)), 2) + Right("0" + CStr(Hour(Now)), 2) + Right("0" +
CStr(Minute(Now)), 2) + Right("0" + CStr(Second(Now)), 2) + ".txt"
End If
Main = DTSTaskExecResult_Success
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Johnfli" <john@.ivhs.us> wrote in message
news:OFU2fLxiGHA.4204@.TK2MSFTNGP02.phx.gbl...
How can I have a DTS package rename a file?
for example, I have a file c:\temp.txt
I would like to have a DTS package change it to c:\temp060806.txt (the
numbers is teh date)
Thanks
No comments:
Post a Comment