sql server 2005中没有小数位格式 [英] no decimal places formatting in sql server 2005

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

问题描述

您好所有访客
如何将值(194540320)格式化为这样(194,540,320)?
我像这样使用(选择convert(varchar(29),convert(money,Amount),1)as Amount)
从字段中获取数据.但金额显示为小数点后两位(194,540,320.00).
如何格式化不带小数位的金额字段?

最好的问候,

Hi all visitors
how can i format the value(194540320) to like this (194,540,320)?
i used like this( select convert(varchar(29), convert(money, Amount), 1)as Amount)
to get data from field.but the amount show with 2 decimal places(194,540,320.00).
How can i format the Amount field with no decimal places?

Best Regards,

推荐答案

您可以使用LEFT方法来修剪小数位,就像这样

You can use the LEFT method to trim the decimal places, like this

declare @tempStr as varchar(29) 
set @tempStr = convert(varchar(29), convert(money, Amount), 1)
select left(@tempStr, len(@tempStr) - 3) as Amount


这篇关于sql server 2005中没有小数位格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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