SSIS - How To Create Fixed Width Columns Text File in SSIS

Scenario: 

As ETL developer, we get different type of requirements to generate different types of files. In this post we need to create a text file with fixed width columns. We are going to get the data from our SQL table and then create the file.

Solution:

We will be using the Flat File Destination to create the Fixed Width Columns text output file from SQL server table. Let's Start with Step by Step approach.

Step 1:

Create new SSIS Package. Inside the SSIS Package, Bring the Data Flow Task to the Control Flow Pane.Bring OLE DB Source inside the Data Flow Task. Create the Connection and Choose the table/view from which you want to get the data.
Fig 1: Configure OLE DB Source To Get Data from SQL Table

Fig 2: Choose the Columns From OLE DB Source

Step 2:

Bring the Flat File Destination and connect OLE DB Source to it.  Once connected, configure as shown below
Fig 1: Configure Flat File Destination for Fixed Width Column Output File

If you want to have header row then check the Box: Column names in the first data row. By using Browse you will be telling where to save the text file.
Fig 2: Create Flat File with Fixed Width in SSIS Package


This is important step, You will choose the column length in this. You can adjust according to your input data length.
Fig 3: Fixed Width File in SSIS Package, Choose InputColumnWidth and OutputColumnWidth

Map the input columns to output columns
Fig 4: Create Fixed Width Column File in SSIS Package, Map the input columns to output columns


SSIS Package is completed, Let's run the SSIS Package and check if the output file is created as Fixed Width Column.
Fig 5: Fixed Width Column Text File is created by using SSIS Package


If you are interested to watch this post as video