Trim Functions in SSIS

In T-SQL there are many functions there to help do a variety of different things.  SSIS is no different.  In fact, a good number of the commonly used functions from T-SQL are in SSIS as well.  Here we will explore the different Trim functions found in SSIS.
We will be using the test phrase ”      Test      ” to illustrate the three functions: LTRIM, RTRIM and TRIM.
LTRIM (Left Trim):
Just as in T-SQL, this removed empty spaces from the beginning (or left) of a string.

Notice the highlighted result that the trailing spaces are still present but the leading spaces are gone.
RTRIM (Right Trim):
Just as in T-SQL, this removed empty spaces from the end (or right) of a string.

Notice the highlighted result that the trailing spaces are gone but the leading spaces are still present.
TRIM:
In T-SQL to remove both leading and training spaces you have to nest the trim statements like this: SELECT LTRIM(RTRIM(ColumnName)) AS ColumnName FROM Table. Luckily in SSIS there is a TRIM function that will remove both leading and trailing space in one function called TRIM.

Notice the highlighted result that the trailing and leading spaces are gone.
 

About the author

Bradley Schacht

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Jacksonville, FL. Bradley is a former consultant, trainer, and has authored 5 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

1 comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Use the below Expression in Derived Transformation it will work
    you can use any LTRIM, RTRIM or TRIM
    if your Source and Destination data type are CHAR, VARCHAR, NVARCHAR
    (DT_STR,50,1252)TRIM(sname)

Bradley Schacht

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Jacksonville, FL. Bradley is a former consultant, trainer, and has authored 5 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

Follow Me