开发者

Using currency $ format with sql server?

I have data in my sql database like 645.000 and i need to fo开发者_运维知识库rmat it to include currency symbols e.g., $645.000

How can I achieve this in SQL?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜