not sure about your source data but I guess you may need to check for nulls as well:
ISNULL(Sndr_Ref) || TRIM(Sndr_Ref) == "" ? (ISNULL(Check_Num) || TRIM(Check_Num) == "" ? (DT_WSTR,50)NULL(DT_WSTR,50) : "2") : "10"
Question
I have a source table with two columns - Sndr_Ref and Check_Num
I have a target table with one column - Txn_Code (nvarchar(50),null)
Here is the logic I need to implement -
I created a derived column in my SSIS package which I mapped to Txn_Code. Here is the expression of my derived column -
Sndr_Ref == "" ? (Check_Num == "" ? (DT_WSTR,50)NULL(DT_WSTR,50) : "2") : "10"
The above expression is inserting 10 in all records. No nulls or 2 are being inserted. I checked the source table and there should be some records with 10, 2 and nulls in target column. I just found out that my source reference columns (Sndr_Ref and Check_Num) have widespaces. Could you please help how can I trim those widespaces in my above logic and set the value to null if they are blank?
Solution
not sure about your source data but I guess you may need to check for nulls as well:
ISNULL(Sndr_Ref) || TRIM(Sndr_Ref) == "" ? (ISNULL(Check_Num) || TRIM(Check_Num) == "" ? (DT_WSTR,50)NULL(DT_WSTR,50) : "2") : "10"