SSIS LTRIM function

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

LTRIM(<<Character_expression>>)

To demonstrate the SSIS LTRIM 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 LTRIM function

To remove leading 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 LTRIM function expressions and create new columns.

Data Flow to add Derived Column

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

LTRIM( [Education] )
SSIS LTRIM 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 LTRIM function package to see the Education column with removed left side or leading spaces.

SSIS LTRIM Function  output