August 15, 2012 at 9:56 pm
I need to create an SSIS fixed width export with multiple output record types. Can someone point me at a good link on this one? I've found a lot on multiple record type IMPORTs (frankly that doesn't look real pretty, glad I'm exporting not importing). But I can't find too much on EXPORTs. I've done plenty of SSIS exports in my time, but this is the first one I've come across with multiple record types.
.
August 17, 2012 at 3:17 pm
does each record type have different columns / widths?
is each record type running in different data flows with different formatted output that all need to go into the same file?
If that is the case I would setup a script component on the output of each data flow and use
something like
public class ScriptMain : UserComponent
{
var sb = new StringBuilder();
...
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
// clear the string builder
sb.Remove(0, sb.Length);
// use the append format to build the output string
// add in some padding, the output of fld1 will be left justified and padded out to a total of 40 characters wide
sb.AppendFormat("{0}{1}{2}{3}{4}{5}", Row.fld1.PadRight(40,' '), Row.fld2, Row.fld3, Row.fld4, Row.fld5,Environment.NewLine);
File.AppendAllText("C:\\Myfile.txt", sb.ToString());
}
This way you only need to specify a variable for the output file path (which you would use in place of the hardcode path above.)
no file connections need to be specified. The file is automatically created if it does not exist.
run the data flows in series to avoid contention with the file, each record format will be in it's own section of the file.
Hope I'm not way off base on this.
August 17, 2012 at 8:42 pm
Perfect. Thank you Tom. Exactly what I am looking for.
.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply