Coming from an Oracle background I cannot believe how SQL Server is giving me such a hard time for such a trivial concern.
I only want to parse numbers from a varchar column into a numeric column. The thing is, numbers are not in US style but German style format. That means, the decimal mark and digit group separator are interchanged.
Example:
1.767,13 equals one thousand and seven hundred ...
I kind of looked through every MSDN article. CAST doesn’t accept any additional parameters. CONVERT can take a style which though seems to only apply for date/time and money conversion. Further I found TRY_PARSE which takes a culture parameter but doesn’t seem to be available yet in the 2008 version.
I came up with a kludge solution, but that cannot be it!
cast(replace(replace([TOTALVALUE],'.',''), ',','.') as numeric(20,2))
First the digit group separators get removed and then the decimal mark gets changed from comma to dot. It works, but is it robust etc.
Thanks for comments and answers!
Sorry to disappoint but yes,
is the way to do it.