SSIS string funtion REPLACE in expression
I am importing a text file with amount columns in the format of 99,999.00 or 99,999.00-. The data destination is SQL Server table column numeric. I am using SSIS package with derived column task. I need to remove the "," and "-" and then multiple by -1 if "-" is found. Here is the expression syntax, I am struggling with. Can someone help? I found VB function, but since I am not VB literate, I would prefer not to use that. Can you replace multiple characters with string function in SSIS expression? LEN(TRIM(Balance)) == 0 ? 0 : FINDSTRING(Balance,"-",1) > 0 ? (DT_NUMERIC,18,2)REPLACE(REPLACE(Balance,",","","-","") ) * -1) : (DT_NUMERIC,18,2)REPLACE(Deferred_Sales_Balance,",","")
March 16th, 2011 4:35pm

Following expression will remove "-" from the value and multiply it by -1. Check this:(DT_NUMERIC,18,2)(FINDSTRING(REPLACE(Num,",",""),"-",1) > 0 ? "-" + REPLACE(REPLACE(Num,",",""),"-","") : REPLACE(Num,",","")) You can do the null check and ZERO length check also in the above expression.Nitesh Rai- Please mark the post as answered if it answers your question
Free Windows Admin Tool Kit Click here and download it now
March 16th, 2011 6:02pm

Nitesh, It did not work exactly as you stated because of the concatination to create a numeric value. What actually worked is this LEN(TRIM(column_name)) == 0 ? 0 : (DT_NUMERIC,18,2)(FINDSTRING(column_name,"-",1)) == 0 ? (DT_NUMERIC,18,2)REPLACE(column_name,",","") : ((DT_NUMERIC,18,2)REPLACE(REPLACE(column_name,"-",""),",","")) * -1 You got me on the right track Thanks
March 17th, 2011 2:28pm

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

Other recent topics Other recent topics