How do I change a whole number that is a DT_R8 in SSIS to a decimal number? I have some that have decimals and some that dont in my excel spreadsheet that I'm converting. For example I may have the following:
8512
8134.5
8003.27
7964.97
7250
Id like for them to all read this:
8512.00
8134.50
8003.27
7964.97
7250.00
Ive tried using DT_DECIMAL,2
in my der开发者_如何学JAVAived column but it doesn't seem to work. I have it as follows: (DT_DECIMAL,2)((DT_DECIMAL,2)[Debit Amt])
Thanks
If I understood correctly, your input and output is an Excel spreadsheet.
From: http://technet.microsoft.com/en-us/library/ms141683.aspx
Data types. The Excel driver recognizes only a limited set of data types. For example, all numeric columns are interpreted as doubles (DT_R8), and all string columns (other than memo columns) are interpreted as 255-character Unicode strings (DT_WSTR). Integration Services maps the Excel data types as follows:
Numeric – double-precision float (DT_R8)
So, I think the only solution is to save it like a string in the spreadsheet, concatenating as many zeros as needed on the right. Here is the code for the derived column with a precision of 3 decimals.
FINDSTRING((DT_WSTR,50)(DT_DECIMAL,3)[Debit Amt],",",1) == 0 ? (DT_WSTR,50)(DT_DECIMAL,3)[Debit Amt] + ",000" : (DT_WSTR,50)(DT_DECIMAL,3)[Debit Amt] + REPLICATE("0",4 - LEN(SUBSTRING((DT_WSTR,50)(DT_DECIMAL,3)[Debit Amt],FINDSTRING((DT_WSTR,50)(DT_DECIMAL,3)[Debit Amt],",",1),LEN((DT_WSTR,50)(DT_DECIMAL,3)[Debit Amt]))))
精彩评论