Using currency $ format with sql server?

眉间皱痕 提交于 2019-12-02 13:12:49

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.

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!