Hi,
I have an SSIS 2008 package which uses a For Each loop that enumerates a bunch of csv files and imports data to an OLE DB table. The loop maps the file name to variable FileName. I also have a fixed string variable called FolderPath with the path to the folder that contains the source files. In the data flow task, I assign the flat file connection string to @[User::FolderPath] + @[User::FileName]. So far, no problems. Everything works as expected.
The issue is that I also need to pass FileName to the same DB table as another column. So if I have file123.csv that contains 10 rows of data, there would be an additional column in the DB table with the value "file123.csv" for all 10 rows, and so on for each file. To accomplish this, I set up a Derived Column where I add a new column with the expression @[User::FileName]. The problem is that only blank ("") values are imported into the DB table for FileName. Clearly the variable has the correct value or the source connection string would fail. But for some reason that value doesn't make it to the output.
Incidentally, I have another variable DateSent evaluated as an expression based on the variable FileName, as the file names all contain the same convention with date stamp. When I try to pass DateSent to the DB as a new Derived column, NO data (i.e. zero rows) is inserted into the table, although the package runs successfully and even shows the correct number of rows in the data flow for each file as the loop is running. This isn't a huge deal since I can always run a SQL update statement to populate DateSent after the fact, but this relies on Filename being imported to the table.
Any help is appreciated. Thanks.