SSIS Export SQL Data to Fixed Width Flat File

This SSIS article shows how to export SQL Server table records or data to a fixed width flat file.

The below screenshot shows the rows in the Employee table.

Employee table

SSIS Export SQL Data to Fixed Width Flat File

Drag the Data Flow Task into the control flow region.

Add Data Flow Task

Double-click to open the SSIS Data Flow Region. Then, drag the OLE DB Source and double-click on it to open the Editor. Next, click the New button to configure the OLE DB Connection Manager.

Here, we have chosen the existing one, but you can create a fresh one by clicking the New button.

Add OLE DB Source to configure oledb connection manager

We choose the Employee table from the list of available ones. Next, go to the columns tab to check the columns and click the OK button.

choose the Employee table

Drag the flat file destination and connect the OLE DB source to it. Next, Double-click on the flat file destination to open the Editor, and click on the new button to choose the Fixed Width as the flat file format.

SSIS Export SQL Table to Fixed Width Flat File Destination 1

Click the Browse button to create a new file to store the Fixed Width records.

Browse File

Next, checkmark the Column Names in the first data row option to copy the headers.

Checkmark the Column Names in the first data row

Within the Advanced tab, change the InputColumnWidth value to adjust the row items. For instance, EmpID = 8, FirstName = 25, etc.

SSIS Export SQL Data to Fixed Width Flat File InputColumnWidth

Change the InputColumnWidth value for the remaining columns. After you finish, click OK to close the window.

Change the InputColumnWidth value

Within the Flat File Destination Editor, go to the Mappings tab to check the input and available destination column mapping.

Check the input and available destination column mapping

Run the SSIS Export SQL Server Table Data to Fixed Width Flat File package.

Run the SSIS Export SQL Server Table Data to Fixed Width Flat File package

As you can see, the text file has all the records in a single line or row where a Fixed Width of space separates each value.

SSIS Export SQL Server Table Data to Fixed Width Flat File Output