if statement - SSIS Derived column padding of leading zeroes -


i want able add leading zeroes in following scenarios -

  1. i need leading zeroes before [account id] if [account id] < 17 {for application = rcc, sec, hogan cis}

  2. i need leading zeroes before [account id] if ([account id] + [account number]) < 17 {for application = cln}

  3. i need leading zeroes before [client key] if ([client key] + [client id]) < 17 {for application = itf}

i have following expression defined in derived column -

 ltrim(rtrim(application == "rcc" || application == "sec" ? application + "|" + [account id] : application == "hogan cis" ? (hogan_hogan_alpha_product_code == "dda" ? "dda" : "tda") + "|" + [account id] : application == "itf" ? application + "|" + [client key] + [client id] : application == "cln" ? application + "|" + [account id] + [account number] : application + "|" + [account number])) 

padding strings

the general strategy use when dealing adding leading characters add them , take n rightmost characters. find simplifies logic.

right(replicate('0', 17) + [mycolumn], 17) 

that generate 17 zeros, prepend column , slice off last 17 characters. if mycolumn 17 character, no effective work done. if empty, have value of 17 zeros.

choosing

in case, i'd first try add derived column identify block of logic application falls into. existing ternary expression have.

(application == "cln") ? 10 :      (application == "itf") ? 20 :     (application == "rcc" | application == "sec" ....) ? 30 : 40 

coming out of derived column, you'll able verify logic working expected makes padding easier scenario.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -