home
training courses
why choose us?
solutions
support
company
LearnItFirst User Forum
Welcome Guest
Search
|
New Posts
|
Members
|
Log In
|
Register
SQL Server Forum - LearnItFirst.com
»
SQL Server Database Administration
»
Integration Services (SSIS) and DTS
»
How do you copy a file to another folder using the current datetime as part of the file name?
How do you copy a file to another folder using the current datetime as part of the file name?
Options
Previous Topic
·
Next Topic
WayneL15
Posted:
Monday, May 11, 2009 11:50:19 AM
Rank: Newbie
Joined: 3/25/2009
Posts: 5
Points: 15
Where do you live?: New York
I have an SSIS package that:
1. Via execute task, exports data to a flat file using BCP to the local file system. D:\output\myfile.txt
2. Sends the file to another server via FTP.
Now I need to copy the file as an archive file to a different folder on the same local server.
I would like the file to be renamed from D:\output\myfile.txt to D:\output\Success\myfile_YYYYMMDD_HHMM.txt
arkblue">
I think the following could be used to generate an archive file name, but I am not sure where and in which object this should be placed to work properly.
@[User::ArchivePathSuccess] + @[User::SuccessCopyFileNamePrefix] + REPLACE(REPLACE( SUBSTRING( (DT_WSTR, 30) GETDATE(), 1, 17 ) , " ", "_"
,":",""
+".txt"
The variables have been set as follows: ArchivePathSuccess = D:\output\success\ SuccessCopyFileNamePrefix = myfile
Any suggestions?
Thank you for yor help in advance.
Back to top
WayneL15
Posted:
Monday, May 11, 2009 2:11:01 PM
Rank: Newbie
Joined: 3/25/2009
Posts: 5
Points: 15
Where do you live?: New York
Found this link:
http://rafael-salas.blogspot.com/2007/03/ssis-file-system-task-move-and-rename.html
Also how might you delete files older than a certain date from a folder.
Thank you.
Back to top
Scott Whigham
Posted:
Tuesday, May 12, 2009 11:58:39 AM
Rank: Super Mod
Joined: 3/20/2006
Posts: 476
Points: 1,053
Where do you live?: Dallas, TX
Very nice - thanks!
Back to top
Users browsing this topic
Guest
Forum Jump
SQL Server Database Administration
- General SQL Database Question & Answer
- Backup, Recovery and Disaster Recovery
- SQL Server Security
- Integration Services (SSIS) and DTS
Transact-SQL Programming
- DML (SELECT, INSERT, UPDATE, DELETE) Questions
- Stored Procedures, Triggers, & Functions
SQL Server Scripts, Code Samples and SSMS Custom Reports
- All SQL Server Versions
- SQL Server 2005/2008
- SQL Server Management Studio Custom Reports
Customer Service
- Video Requests
You
cannot
post new topics in this forum.
You
cannot
reply to topics in this forum.
You
cannot
delete your posts in this forum.
You
cannot
edit your posts in this forum.
You
cannot
create polls in this forum.
You
cannot
vote in polls in this forum.
SQL Server 2005 DBA Training Videos
SQL Server 2008 DBA Training Videos
Email this topic
RSS Feed
Watch this topic
Print this topic
Normal
Threaded