如何在SQL SERVER中将浮点数转换为本地货币格式 [英] How to conver float numbers to local Money Format in SQL SERVER

查看:220
本文介绍了如何在SQL SERVER中将浮点数转换为本地货币格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想将浮点数类型转换为本地货币格式,但SQL SERVER不接受我的转换功能。



这里我的转换解决方案:



Hi,

I want to conver float number type to local money format but SQL SERVER not accept my convert function.

Here My Converting solution:

FORMAT(360.3678,'c','tr-TR')





所以输出应该是这样的:





So output should like this:

36.036,78





但它的错误:





But its getting error with this:

'FORMAT' is not  recognized built-in function name.





我该如何解决这个问题?



谢谢



How can I solve this issue?

Thanks

推荐答案

从2012版开始提供FORMAT功能。在早期版本中,使用此



转换(货币,圆(360.3678,2))或演员(360.3678作为货币)
FORMAT function is available from version 2012 onwards. In earlier versions, use this

convert(money,round(360.3678,2)) or cast(360.3678 as money)


作为 Tomas Takac [ ^ ]提到,SQL Server 2012和更新版本支持Format函数。



实现这一目标的唯一方法是编写自定义功能 [ ^ ]返回以您想要的方式格式化的文本。



参见:CAST AND CONVERT [ ^ ]和 STRING功能 [ ^ ]



试试!
As Tomas Takac[^] mentioned, Format function is supported in SQL Server 2012 and newer.

The only way to achieve that, is to write custom function[^] which return a text formated the way you want.

See also: CAST and CONVERT[^] and STRING functions[^]

Try!


这篇关于如何在SQL SERVER中将浮点数转换为本地货币格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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