Question

I am having a bit of a struggle with Expressions inside SSIS Derived Columns.

My source field is a BOOLEAN data type. It's destination field is a SQL CHAR datatype.

** Note that I did not design either of the schemas. If I had my way, the data types would match up. Unfortunately, this is not my case!

I found a great example of a .NET Regular Expression converting CHAR-to-BOOL. This does the exact opposite of what I am trying to accomplish:

[valToTranslate] == "Y" ? (DT_BOOL)1 : [valToTranslate] == "N" ? (DT_BOOL)0 : NULL(DT_BOOL)

I have tried to implement the reverse formula of this expression with no success. Here is my failing attempt:

[valToTranslate] == 0 ? (DT_WSTR,1)"N" : [valToTranslate] == 1 ? (DT_WSTR,1)"Y" : "N"(DT_WSTR)

I am not sure if the CAST to (DT_WSTR,1) is even correct for CHAR SQL datatype fields? Should I be using (DT_STR,1) instead? Any help is greatly appreciated.

Was it helpful?

Solution

Have you tried just a straightforward

[valToTranslate] ? "Y" : "N"

That should work - you may need to cast the Y and N to DT_STR, if it assumes they're WSTR by default.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top