SSIS TRIM Function

The SSIS TRIM is a string function that removes the leading and trailing blank spaces from the given string column or character expression and returns a string. This article explains how to use the TRIM function with an example. The TRIM syntax for removing the leading (leftmost) and trailing (rightmost) blank spaces from the character expression is shown below.

TRIM(<<Character_expression>>)

To demonstrate the SSIS TRIM function, we use the Employee table below, which has 15 records. Please refer to the Union All Transformation, Derived Column Transformation, Built-in Functions, and SQL Server articles in SSIS.

Source Table

SSIS TRIM function

To remove leaking and trailing spaces, add a Data Flow Task and double-click on it to enter the Data Flow region. Next, add the OLE DB Source to read data from the above SQL database table. Please join the OLE DB Source to Derived Column Transformation to write TRIM function expression and create new column.

Data Flow to add Derived Column

Next, double-click on it to open the Derived Column Transformation Editor. Drag and drop the SSIS TRIM function to the row cell under the Expression and replace the Character_expression with the string column, i.e., Education. Either you can manually delete the complete Character_expression or drag and drop the Education column will automatically replace it.

TRIM( [Education] )
SSIS TRIM Function Expression

Click OK to close the Editor window.

Drag and drop the Union All Transformation and connect the Derived Column to it. Next, right-click on the connection node and choose the Enable Data Viewer. Please run the SSIS TRIM function package to see the Education with removed left part (leading) and right part (trailing) blank spaces.

SSIS TRIM Function to. remove leading and trailing spaces