Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Trim function not removing space when the column only contains a single SPACE

$
0
0

I'm using the following Derived Column Expression to trim the white spaces around my column. The column is defined using a Flat File Connection as a string[DT_STR] with width of 50. If the column contains only a single SPACE character (Hex 20), I want to set it to NULL, but the expression is keeping the single SPACE in the column.

   LEN(TRIM(Student_EMail_Address)) > 0 ? TRIM(Student_EMail_Address) : (DT_STR,255,1252)NULL(DT_STR,255,1252)

I found an MSDN article that states the following : (http://msdn.microsoft.com/en-us/library/ms139947.aspx)

     TRIM works only with the DT_WSTR data type. A character_expression argument that is a string literal or a data column with the DT_STR data type is implicitly     cast to the DT_WSTR data type before TRIM performs its operation. Other data types must be explicitly cast to the DT_WSTR data type.

Does this mean that I need to type cast the column as DT_WSTR before I call the TRIM function?

      LEN(TRIM((DT_WSTR,20)Student_EMail_Address)) > 0 ? TRIM((DT_WSTR,20)Student_EMail_Address) : (DT_STR,255,1252)NULL(DT_STR,255,1252)

  


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>