更改sql中的Money格式列 [英] Changing the Format of Money column in sql

查看:69
本文介绍了更改sql中的Money格式列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我想知道如何更改SQL Server中money栏的格式。



目前在我的数据库中,money栏显示为1234,56



我想要它是1234.56



任何想法我怎么能改变这个?

Hi


I would like to know how would i be able to change the format of the money column in SQL Server.

Currently on my database the money column is showing as 1234,56

I would like it to be 1234.56

any idea how i could change this?

推荐答案

你不应该在sql级别。在2012版中,您可以使用特定于文化的格式(请参阅 MSDN [ ^ ]),但在此之前你只能解决这个问题字符串操作,看起来可能看起来不错,但这是一个坏主意,因为这应该是表示层(用户界面,报告工具,无论......)的关注,而不是数据存储。



但是如果你坚持这种方法,请从这里开始: http:// sqlusa.com/bestpractices2005/moneyformat/ [ ^ ]。除了展示的可能性之外,您还可以为此任务制作CLR集成功能。这是DateTime格式化的示例,但它很容易适应您的需求: http ://sqlsteve.com/2009/05/13/sql-server-datetime-format-function/ [ ^ ]。
You should not address this task on sql level. In version 2012 you have the possibility to use culture specific formatting (see MSDN[^]), but before that you can only solve this by string manipulation, which might look good at first sight, but is a bad idea, because this should be a concern of the presentation layer (user interface, reporting tool, whatever...), not of the data store.

But if you stick to this approach, start here: http://sqlusa.com/bestpractices2005/moneyformat/[^]. Beside the possibilities demonstrated there you can also make CLR integrated function for this task. This is a sample for DateTime formating, but it is quite easily adaptable to your needs: http://sqlsteve.com/2009/05/13/sql-server-datetime-format-function/[^].


ALTER TABLE table_name
ALTER COLUMN column_name datatype


这篇关于更改sql中的Money格式列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆