Search code examples
numbersformatsybase

Thousand separator (.) and decimal place with , in SQL sybase


I am having the problem that I should format any number in the following style in SQL ( Sybase ).

5123456789,99 --> 5.123.456.789,99

The only way that I found was:

select convert(varchar, cast(5123456789.99 as money), 1) --> 5,123,456,789.99

but this is the other way around :( Is it somehow possible to get the thousand operator with a dot instead of comma? Thank you very much!


Solution

  • This should work:

    SELECT REPLACE(
       REPLACE(
           REPLACE(
               CONVERT(varchar, CONVERT(money, 5123456789.99), 1), ',', ' '
           ), '.', ','
       ), ' ', '.'
    );
    

    It's not pretty though.