Handling flat file destinations dynamically

  • This is regarding a SSIS package.

    After performing a join operation on two tables i get the below resultset

    pid, fname, typename, pname, pcost

    1, cad, bars, product-1, 100

    2, har, witte, product-2, 120

    3, nes, bars, product-3, 119

    .....................................................

    Now i need to create files with the obtained resultset like

    Column 'fname' is the folder name and 'typename' should be the file in the particular folder.

    For example the first record should be inserted into file name 'bars.txt' in the folder 'cad'

    and third record should be created in file name 'bars.txt' in the folder 'nes'.

    Could someone please help me with this?

  • This is probably more complicated than you would like. It is possible to make destinations dynamic with expressions, but not really at the row level.

    So you will first need a data flow off of a query that puts folder and file name together, and gets all the distinct possibilities, and puts them in a recordset.

    Then you will need a foreach loop that loops through the recordset, setting a variable to the file path and destination. Within it you can put a data flow that in the source only queries records going to that destination, and your file destination can have a file name expression on the variable.

  • If you only have a few (lets say a couple of dozen at most) and the combinations are static (i.e. you know them in advance) you could use a conditional split based on the column values to divert the data to the correct file; I would recommend a catch-all for anything that is not satisfied by the conditional split evaluations.

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

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