The SSIS RTRIM is a string function that removes the trailing spaces from the given string column or character expression and returns a string. This article explains how to use the RTRIM function with an example and the syntax for removing the trailing or rightmost spaces from the character expression is as shown below.
RTRIM(<<Character_expression>>)
To demonstrate the SSIS RTRIM 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.
SSIS RTRIM function
To remove trailing spaces, please 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 because it helps to write RTRIM function expressions and create new columns.
Next, double-click on it to open the Derived Column Transformation Editor. Drag and drop the SSIS RTRIM function to the row cell under the Expression and replace the Character_expression with the string column (Education). Either you can manually delete the complete expression or drag and drop the column will automatically replace it.
RTRIM( [Education] )
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 RTRIM function package to see the Education column with removed right side or trailing spaces.