How to convert a string to money in the Data Conversion Transformation process in SSIS?
My Source file is an Excel File. I added the Data Conversion Transformation to convert the Price
column to the Data Type "currency[DT_CY]
".
Source value : $50,240.30
Expected result : 50240.30
SQL Destination table has the column Price with the Data Type : Money
However, conversion fails with the following error :
The "Data Conversion.Outputs[Data Conversion Output].Columns[Price]" failed because error code 0xC020907F occurred, and the error row disposition on "Data Conversion.Out
This query works.. fine.. However, this query is applied only after we received the data to the Table.
We are trying to get the data while loading into the table as "Money" data type.
select convert(MONEY, [Price]) AS [Price] , * from dbo.StagingTable
Per Nick's comment, source file conversion is working fine. However, we need the string to be converted to Money data type.
Source Price : $55,176.80
Derived Column Expression : REPLACE(REPLACE([Price],"$",""),",","")
Data Type : DT_WSTR
Output Price : 55176.80
$
and,
characters first – Nick.McDermaidREPLACE(REPLACE(<yourcolumn>,'$',''),',','')
docs.microsoft.com/en-us/sql/integration-services/expressions/… – Nick.McDermaid"
instead of'
for string literals. I can never remember and the help doesn't contain any examples, TryREPLACE(REPLACE(<yourcolumn>,"$",""),",","")
– Nick.McDermaid