I am wanting to capture the file name I am using to load data from and use it in a SQL statement to insert it along with the data that I load.
I am using a ForEach container to load all my .txt files but cannot figure out how to capture the name of each source file as it loops through the files and then add it to my insert statement that is populating my history table. I would think that the ForEach container has that information, but I do not see how to access it and assign it to a variable that I could use in my SQL statement.
Any ideas or suggestions?
The ForEach loop container can store the name of eac enumerated file into a variable. This article explains how to do that: http://blogs.conchango.com/jamiethomson/archive/2005/05/30/1489.aspx
Once its in a variable you can do pretty much anything you want with it and it seems you already know how to do that. If not, just reply here.
-Jamie
|||
Thanks for the link, but I have was able to setup a variable @.[User::FN] to the ConnectionString property associated with the flat file connection, and the looping and loading effort is working fine.
This may seem like a stupid question, and I apologize, but I cannot figure out how to reference that variable and use it in my execute SQL task that follows later and does my insert of the data into my table. What I want to do is something like this:
Insert into Table1 Select a, b, c, @.FN From Table2
The parser requires that I declare the variable and does not seem to recognize the @.[User::FN] variable.
Any suggestions?
|||Yes, use an expression. This (sort of) shows you how:
http://blogs.conchango.com/jamiethomson/archive/2005/12/09/2480.aspx
-Jamie
No comments:
Post a Comment