--SQL中转换money类型数值转换为字符串问题,直接转换就转为两位了,所以需要做一下处理。具体请看下述sql实例。


1
create table #test(price money) 2 3 insert into #test values (45.2525) 4 5 6 7 select cast(price as varchar(50)) from #test   --输出45.25 四位小数只有两位了 8 select convert(VARCHAR,price) from #test      --输出45.25  四位小数只有两位了 9 10 select convert(VARCHAR,45.2525)   --输出为45.2525 四位小数 11 12 13 14 select cast(CAST(price AS DECIMAL(20,4)) as varchar(50)) from #test   --输出为45.2525 四位小数 15 select convert(VARCHAR,convert(DECIMAL(20,4),price)) from #test   --输出为45.2525 四位小数 16 17 DROP TABLE #test

 

posted on 2016-07-20 15:18  yxtic  阅读(5937)  评论(0编辑  收藏  举报