July 21, 2014 at 11:00 am
I need some help in coding for a script task for a SSIS package.
I have a folder called TestFile in D:\, and I am placing a text file with the name starting with E, and want to rename it as testfileYYYMMDD.txt.
So, here is what I try to write for the script task:
Public Sub Main()
Dim sSourceFile As String
Dim sDestinationFile As String
sSourceFile =
sDestinationFile = "d\test\"testfile" + Date.Now.ToString("yyyyMMdd") + ".txt"
'System.IO.File.Move(sSourceFile, sDestinationFile)
System.IO.File.Move(sSourceFileA, sDestinationFileA)
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
July 21, 2014 at 11:11 am
Why are you using script task to do this? Doesn't a file system task meet your needs?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
July 21, 2014 at 11:11 am
QQ-485619 (7/21/2014)
I need some help in coding for a script task for a SSIS package.I have a folder called TestFile in D:\, and I am placing a text file with the name starting with E, and want to rename it as testfileYYYMMDD.txt.
So, here is what I try to write for the script task:
Public Sub Main()
Dim sSourceFile As String
Dim sDestinationFile As String
sSourceFile =
sDestinationFile = "\\co-2K3fsa03\DATA2\MCO\ELDERPLAN\Interfaces\EOP\ToEmdeom\" + Date.Now.ToString("yyyyMMdd") + "HZBER8F22ABF" + ".txt"
'System.IO.File.Move(sSourceFile, sDestinationFile)
System.IO.File.Move(sSourceFileA, sDestinationFileA)
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
So, why are you doing a MOVE? Why not just use a good ol' fashioned DOS RENAME command?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 21, 2014 at 11:15 am
To answer the rest of your question (how to get the source file) from this thread, http://www.sqlservercentral.com/Forums/Topic1594694-391-1.aspx that I commented was a duplicate.
I'd use the For Each Loop Container which allows you to loop over files in a directory and then use the File System Task within the loop to process/rename/move the file.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply