How to get the Source file name from table for Data flow Taks?

  • Hi,

    I want to load the data from one CSV file. But file name should come from the table because every cycle file name will vary. Instead of hard coding in data flow task (FLat file Source), is there any other way to do this?

  • create an 'Execute SQL Task'. The SQL-Statement can be something like 'select filename from tablename'

    Choose 'single row' for the ResultSet

    In the ResultSet Tab set ResultSetName 0 and Variable Name to a UserVariable (i.e. filename)

    In the Dataflow create a Flat File Connection. Choose Properties of the FlatFileConnection and set the connectionstring to your UserVariable

  • Thanks its working fine.

    I need to load the data from excel file assume that its contains two columns. Excel file name contains the period is like "M0209". So file name will be M0209.xls. My target table is having 3 columns one for period and another two cols is same source column.

    How to read the file name and same value needs to be inserted into period column in the database.

    Can you help me on this?

  • First insert the data colums in your table.

    Please try an 'Execute SQL Task' with an ADONET-Connection to your database. In the SQL-statement use 'insert into yourTable (filenamecolumn) values (substring(@yourVariableContainingTheFilename,2,4))

    where filenamecolumn is null

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply