In a SQL Server money column how can I deal with different currency notations coming in from country specific Excel files via SSIS (in varchar – transformed to money), taking care of comma and dot representation to make sure the values stay correct?
For example if these are three column values in Excel:
22,333.44
22.333,44
22333,44
the first notation above will result in 22,3334, which of course is incorrect.
What do I need to do with the data? Is it a string replace or something more elegant?
thank you.
UPDATED:
After discussion in comments the problem has been clarified. The values in the excel column can be of many different regional formats (English using commas to separate thousands and ‘.’ for decimal point, German using ‘.’ for separating thousands and comma for decimal point).
Assuming that the destination format is English and you don’t have an accompanying column to indicate the format then you’re gonna have to implement a kludge of a workaround. If you can guarantee there will always be 2 numbers after the “decimal place” (comma in german format) then REPLACE(REPLACE(@Value,’,’,”),’.’,”) will get rid of every comma/point. Then you will have to get the length of the resulting varchar and manually insert a decimal (or comma) before the last 2 characters. Here’s a sample implementation:
And the results:
Original Answer:
I may be misunderstanding your question but if you take in those values as VARCHAR and insert them into MONEY columns then the implicit conversion should be correct.
Here’s what I’ve knocked together to test:
And the results: