Problem in Derived Column
I have a derived column and it is doing a complex expression : Second_Loan_Interest_Rate == "" ? Second_Loan_Interest_Rate : (ISNULL(FINDSTRING(Second_Loan_Interest_Rate,"%",1) != 0 ? SUBSTRING(Second_Loan_Interest_Rate,1,FINDSTRING(Second_Loan_Interest_Rate,"%",1) - 1) : Second_Loan_Interest_Rate) ? "0.00" : ((DT_DECIMAL,2)(FINDSTRING(Second_Loan_Interest_Rate,"%",1) != 0 ? SUBSTRING(Second_Loan_Interest_Rate,1,FINDSTRING(Second_Loan_Interest_Rate,"%",1) - 1) : Second_Loan_Interest_Rate) >= 1 ? (DT_STR,30,1252)((DT_DECIMAL,2)(FINDSTRING(Second_Loan_Interest_Rate,"%",1) != 0 ? SUBSTRING(Second_Loan_Interest_Rate,1,FINDSTRING(Second_Loan_Interest_Rate,"%",1) - 1) : Second_Loan_Interest_Rate) / 100) : (FINDSTRING(Second_Loan_Interest_Rate,"%",1) != 0 ? SUBSTRING(Second_Loan_Interest_Rate,1,FINDSTRING(Second_Loan_Interest_Rate,"%",1) - 1) : Second_Loan_Interest_Rate))) It is checking many conditions i.e. null value , "%" string, diving the value by 100 if > 1. The problem is that where the conversion of the value >1 is taking place , the answer is coming as .xxx but i need the answer as 0.xxx By removing the string is not a happening because where the data is imported is a table with data type as varchar and doesnt accept nulls. please can somebody suggest me solution to this. Thank You, Rashmitarun
May 23rd, 2011 11:34pm

Wow that is very difficult to read! You can use a Type Cast to convert the value .xxx into a NUMERIC data type (DT_NUMERIC,8,2)Second_Loan_Interest_RateJeff Wharton MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt) MCT, MCPD, MCITP, MCDBA, MCSD, MCAD
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 12:40am

(Until/unless you have this expression working really well, I'd split it up into two (or more) Derived Column components one after the other, possibly with Conditional Splits to ease the logic.) Jeff is correct - your root problem is type casting. You've got implicit type casting occurring everywhere in that expression. Second_Loan_Interest_Rate is a string, and yet you're comparing it to integers and dividing it. Your problem is that implicit conversion. When you divide by 100, you are asking SSIS to convert the data to (most likely) a floating point representation. Then you're stuffing the result into a string column, causing a conversion back to a string. To SSIS (and most software), ".xxx" and "0.xxx" are exactly the same thing. You're going to have to consciously format the string to how you want it to look - and unfortunately for you, SSIS doesn't have a VB6-esque "Format" function to do so. You're going to need to tack on a "0" to that result yourself. Talk to me now on
May 24th, 2011 12:05pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics