Header and Trailer Record

  • Hello,

    I have an SSIS package which creates a fixed width text file. I now need to add a header and trailer record. I know I can use the script task and use vb.net streamreader to read the file and streamwriter to write the header record, the file, and the trailer record. What I'm curious about is if this can be done using SSIS tasks and not actually reading and rewriting out the file. Streamreader and streamwriter are great, but of course they can add considerable time to a package if the file is big. Can this be done?

    Thanks,

    Strick

  • If it is just a single record at the beginning and another one at the end of the file, you could set up your control flow to have a data flow for the header record, another data flow to append all of your data to the file, and then a final data flow to append the footer record.

    Even with script tasks, I would recommend this approach rather than streaming in all of your data and then trying to insert a header into the beginning of the file.

  • But don't you have to map each one to a single output file--? My header doesn't have the same fields as my detail record or my trailer record. I created a separate header, detail, and trailer file. I've tried to merge and/or UNION but the fields are different among the 3 and it won't let me write to the file. I think I'm going to just execute a process and write a .exe to open the 3 files and write out one file.

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

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