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)
 Dynamically name file?

Author  Topic 

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2005-05-25 : 16:01:13
I have a DTS package that creates an Excel file once a month for my boss. I was just wondering if there is a way to dynamically name the file using a the GETDATE() function or something? Right now I just have this:

\\M\SharedDocs\HUD\OriginalData

But can I do this:
\\M\SharedDocs\HUD\GETDATE()& OriginalData

or something like that?

Thanks!





Brenda

If it weren't for you guys, where would I be?

SreenivasBora
Posting Yak Master

164 Posts

Posted - 2005-05-25 : 17:47:38
Hey,

Please notice that, in my code we are not going to change the original Excel file, we need to create a new file with YYYYMMDD_SAMEFILENAME.xls

Just try this:

Dont do any modification to your package, just select "ActiveX Script Task Proeprties"
write below code...

Function Main()

Dim sFile, sDt, sTime, sFinalPath

sPath = "c:\Temp\"
sFile = "OriginalData.xls"

sDt = Replace(Replace(Replace( now(), ":" ,"") , "/","")," ","")
sFinalPath = sPath & sDt & "_" & sFile

Dim oCD : Set oCD = CreateObject("Scripting.FileSystemObject")
oCD.CopyFile sPath, sFinalPath

Main = DTSTaskExecResult_Success

End Function


With Regards
Sreenivas Reddy B
Go to Top of Page

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2005-05-25 : 18:36:28
Thanks. Cool!

Brenda

If it weren't for you guys, where would I be?
Go to Top of Page
   

- Advertisement -