title: Export SQL Data to Fixed Width Text File with Multiple Record Types
body: <p>I need to create an export of data from SQL Server (multiple tables) into a fixed width text file. The text file will have rows that are different based on the record type.</p>
  
  <ol>
  <li>Header Info (Customer, Address)</li>
  <li>Line Item Info (Customer, Item, Qty)</li>
  <li>Summary Info (Customer, Total Qty)</li>
  </ol>
  
  <p>Any suggestions to accomplish this efficiently?</p>
  
  <p>I'm currently re-casting all columns into char to create the "fixed width" then using SSIS to merge the tables before exporting as a ragged right text file. However, because not all the widths are the same, I'm having to concatenate the line item info into one column to make the merge work. Also, the header info is being merged AFTER the line item info, not before so there's a sorting problem there. Not sure if I'm going down the right path?</p>
  
  <p>Hope that made sense... this export is used to import into a COBOL type system.</p>
  
  <p>Thanks,</p>