Key file creation with Batch Job
I have a batch job that pulls multiple files from FTP sites and saves them into a specified folder. I need the batch job to create a file that has all the names of the files I have downloaded. Is it possible to do this?
October 28th, 2010 10:29am
Yes! Easy in SSIS.
The following SSIS forum is the best fit for your question:
SQL Server Integration ServicesKalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM
Free Windows Admin Tool Kit Click here and download it now
October 28th, 2010 10:35am
Hi,
In SQL Server Integration Services(SSIS), we can use the "Foreach Loop Container" with the "Foreach File Enmerator" to get all files' name, save the each file's name to a file.
Create a SSIS package.
Create a Package variable. Add a "Foreach Loop Container" to the pack. Double-click the "Foreach Loop Container" to open the "Foreach Loop Editor". Go to "Collection" tab, set the "Enumerator" to be "Foreach File Enmerator", set the "Folder" to be the folder we used to stored the files, set other properties.
Go to "Variable Mappings", set the variable to be the variable we defined in step2, Index to be 0.
Click "OK" to apply. Add a "Data Flow Task" to the "Foreach Loop Container". In the "Data Flow Task", add a "Script Component" as source, add the following code to this script component.
this.FileNameOutputBufferBuffer.Column = this.ReadOnlyVariables["Variable"].Value.ToString();
Add a "Flat File Destination", save the file name from the "Script Component" source to this file destination.
If there is anything unclear, please feel free to ask.
Thanks,
Jin ChenJin Chen - MSFT
November 1st, 2010 5:58am