SQL Server 2008: how to format the output as a currency

后端 未结 2 1595
甜味超标
甜味超标 2020-12-18 23:33

I have a query string which returns a value that has several decimal places. I want to format this to a currency $123.45.

Here is the query:

SELECT         


        
2条回答
  •  鱼传尺愫
    2020-12-19 00:06

    Here's a suggestion of the syntax to use to future-proof the search query.

    select format(123.56789,'C2','en-US')  --$123.57 ;
    select format(123.56789,'C3','en-US') --$123.568;
    select format(123.56789,'C0','en-US') --$124
    

提交回复
热议问题