I have a requirement to convert all blank strings in a data flow into NULLs. Here is the expression I tried first:
TRIM( [Some Column] ) == “” ? NULL( DT_STR, [length], 1252) : [Some Column]
This threw an error:
Error at Master DataFlow [Derived Column Task]: For operands of the conditional operator, the data type DT_STR is supported only for input columns and cast operations. The expression “TRIM( [Some Column] ) == “” ? NULL( DT_STR, [length], 1252) : [Some Column]” has a DT_STR operand that is not an input column or the result of a cast, and cannot be used with the conditional operation. To perform this operation, the operand needs to be explicitily cast with a cast operator.
After much messing around, I foud that if I cast the NULL statement as a DT_STR, the expression compiler was happy:
TRIM( [Some Column] ) == “” ? (DT_STR, 8, 1252)NULL(DT_STR, [length], 1252) : [Some Column]
Is this an expected behavior of Integraion Services?
I guess I would have expected that since I specified the type in the NULL statement that I would have to cast it as a DT_STR afterwords.
Any thoughts?
Mark


November 30, 2006 at 2:56 pm |
Thanks! this saved me. I could never figure out why conditional statements would not work, always getting “NULL” is not an input column.
January 11, 2007 at 10:51 am |
Thank you; this also saved me. I think this is poor SSIS design…
March 2, 2007 at 4:25 pm |
Hey, it only took me about an hour of refining my search to find this golden nugget that saved me from having do use script components to do something so simple. I concur that having to cast a null that’s already been cast is redundant. If that’s the case, remove the need to specify the length and code page for the null itself.
June 15, 2007 at 2:12 am |
Thanks for the tip.
I was having trouble processing a fix-width text file, always failing at Data Conversion. I narrowed it down to a Null vs. empty string problem, and after I put the condition in Derived Columns for all columns, the problem is gone.
October 22, 2007 at 4:24 pm |
[...] to this blog entry for pointing me in the right [...]
February 14, 2008 at 5:15 pm |
THANK YOU!!!!
April 2, 2008 at 1:59 pm |
Thanks a million!
May 21, 2008 at 7:18 am |
August 28, 2008 at 4:59 am |
You made my day
October 6, 2008 at 2:32 am |
Thank You.
April 7, 2009 at 2:23 pm |
This saved me too. But it is also weird since I don’t need to do the explicit type cast for other data types. I am able to use NULL(DT_I4) just fine without needing to cast it as DT_I4. For strings it seems weird and redundant, but it works, so thanks!
April 22, 2009 at 9:53 am |
Wow, this is the solution
Casting a NULL value… what was in your mind when you found this solution ?
May 26, 2009 at 11:27 am |
Thanks for this.
The fact that SSIS needs you to do this to avoid an error is stunning.
June 2, 2009 at 6:21 pm |
Hey thanks for the post. This really saved me lot of time.
July 31, 2009 at 7:25 am |
Great!!!!!! That is perfect
October 18, 2009 at 12:55 am |
Many thanks! What crappy design! I’m gonna get some sleep now