Using currency $ format with sql server?

前端 未结 4 1565
面向向阳花
面向向阳花 2021-01-29 06:13

I have data in my sql database like 645.000 and i need to format it to include currency symbols e.g., $645.000

How can I achieve this in SQL?

相关标签:
4条回答
  • 2021-01-29 06:13

    Refer this if you really need to do this from the database rather than from the UI.

    http://www.java2s.com/Code/SQLServer/Data-Type/Formatmoneycurrency.htm

    0 讨论(0)
  • 2021-01-29 06:34

    SQL server has no control over how numbers are displayed in your client application. Modify the application settings, Windows control panel or your program code to change the way numbers are displayed.

    0 讨论(0)
  • 2021-01-29 06:34

    what is the datatype of your column?

    In general currency prefixes should be added only in the UI (User Interface) and at the database level you should work just with numbers. Best data type to store money values is MONEY.

    0 讨论(0)
  • 2021-01-29 06:38

    You don't need to and should not be formatting it in SQL Server - instead it's your application that needs to format it for the UI.

    You didn't say what your application is coded in, e.g. in C# we could use

    Label1.Text = string.Format("Amount is {0:c}", amount);
    

    Then you can be sure that not only will it use the correct currency symbol, it will also use the correct decimal and thousands separator symbols.

    0 讨论(0)
提交回复
热议问题