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

If value matches then use a field value else Null

$
0
0

Greetings, 

I'm creating derived column in SSIS and would like to get some feedback.

Here are the columns in the SQL Server table with raw data.

Select
 account
,type
,payment_date
,payment_amount
from Table1

The requirement is that if "type" = 0, then a derived column, "zero_payment_date", would use "payment date" as its value, otherwise, it should be null. My idea is to create 4 derived columns, "Zero_payment_date" where type = 0, one_payment_date where type = 1, two_payment_date where type = 2. If the type doesn't match then I would want a Null value.

Not sure if this is the most efficient way, but I welcome recommendations.

This is what I have so far with derived column, "zero_payment_date", however, it appears to be failing due to a casting issue.

(DT_DATE)( (DT_UI4) [type]==0 ?  (DT_STR, 12, 1252) [next_payment] : (DT_STR, 12, 1252) "")

By the same token, I need to create 4 derived column to output payment_amount.

If type = 0, then copy payment_amount into derived column, "zero_payment_amount", otherwise set it as NULL.

This is what I have so far for derived column, "zero_payment_amount" but I'm not sure if this is the correct way to parse it.

(DT_NUMERIC, 25,2)( (DT_UI4) [type]==0 ? (DT_NUMERIC, 25, 2) [payment_amount] : (DT_NUMERIC, 25, 2) ))
I'd appreciate if I can get feedback if using the derived columns this way is correct or if there may be another more efficient way. If so, would you kindly guide me to pinpoint how I can resolve what may be a casting issue?

Thank you in advance

Jeannette



Viewing all articles
Browse latest Browse all 24688

Trending Articles



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