views:

1614

answers:

1

Hello, 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.

+3  A: 

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.

Harper Shelby
The SSIS package DOES require that you CAST the field to DT_STR in the Data Conversion task. This does work and is obviously much easier than my approach. I am still curious how to write the complex Expression for this. Thank you for your help, you solved my problem :)
Devtron