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)
 Appending timestamp to ASCII filename

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-06 : 08:03:28
Fred writes "What is the easiest way to append a timestamp to a (destination)textfile filename to make it unique using DTS?"

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-08-06 : 13:57:14
Add ActiveX Script Task (with the script shown below) as the very
first step of your package with 'On Success' workflow from it.


Function Main()
dim p, c, f, n

set f=createobject("scripting.filesystemobject")

n="D:\new" & _
formatdatetime(date) & timer & ".txt"
f.createtextfile n

set p=dtsglobalvariables.parent
set c=p.connections("Text File (Destination)")
c.datasource=n 'here we change Destination File FullName
' to the just now created text file with unique(?) name...


Main = DTSTaskExecResult_Success
End Function

- Vit
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-08-06 : 13:57:35
You could use osql to do this.

osql -Sserver1 -Uuser1 -Psomepassword -q"SELECT GETDATE()" >>C:\Temp\YourFile.txt

osql is a command line utility. It can be used inside your DTS package in the "Execute SQL Task" task. Two > mean to append, one means create a new file.

Tara
Go to Top of Page
   

- Advertisement -