October 12, 2010 at 2:45 pm
I have a package that loads multi flat files from a directory. Each file is named "Business Area - Date (e.g. DDA 10012010). The files do not contain a date field. I'd like to take the "File Name" and insert it into a column while executing the package. Would this be accomplished during a Foreach Loop container? How can I easily capture the file name and insert it into a column? I have considered using the script editor, which seems doable, but was wondering if there is a cleaner method?
October 12, 2010 at 6:08 pm
Hi David,
What's your SQL platform?
Enable XPCmdShellEnabled for 2008 in Facets
October 12, 2010 at 7:21 pm
David.Parks (10/12/2010)
I have a package that loads multi flat files from a directory. Each file is named "Business Area - Date (e.g. DDA 10012010). The files do not contain a date field. I'd like to take the "File Name" and insert it into a column while executing the package. Would this be accomplished during a Foreach Loop container? How can I easily capture the file name and insert it into a column? I have considered using the script editor, which seems doable, but was wondering if there is a cleaner method?
Okay, first you probably should have posted this in the SSIS forums instead.
Yes, you would use a ForEach Container, based on files in a directory. The file name gets put into a variable.
In the data flow task, add a derived column that uses the variable. You now have the file name into a column that can be used in your destination.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
October 13, 2010 at 10:14 am
Thank you for your reply. I've created the variable and will look into the dervied column method.
October 14, 2010 at 11:11 am
I found a setting in the package which captures the filename and path. I was able to capture the date from the filname using an operator on the derived column.
October 14, 2010 at 12:12 pm
So, is this getting you your desired results?
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply