Show comma instead of point as decimal separator(显示逗号而不是点作为小数分隔符)
问题描述
我只想在德国获得正确的数字格式,所以我需要将逗号显示为小数点分隔符而不是点.但是这个……
I just want to get the right number format here in germany, so i need to show commas as decimal separator instead of points. But this...
DECLARE @euros money
SET @euros = 1025040.2365
SELECT CONVERT(varchar(30), @euros, 1)
显示 1,025,040.24 而不是 1.025.040,24(或 1025040,24).在 C# 中提供适当的 CultureInfo 很简单,但如何在 T-SQL 中做到这一点?
Displays 1,025,040.24 instead of 1.025.040,24 (or 1025040,24). In C# it would be simple to provide the appropriate CultureInfo but how to do it in T-SQL?
我真的需要使用 REPLACE 吗?但即便如此,如何正确替换1,025,040.24?
Do i really need to use REPLACE? But even if, how to replace 1,025,040.24 correctly?
推荐答案
好吧,据我所知,没有特定于文化的转换选项可用.
Well, as far as I know, there are no culture-specific options for convert available.
所以你可以使用替换来做到这一点(是的,它看起来有点难看......)
So you can do it using replaces (yes, it looks a bit ugly...)
select
replace(replace(replace(convert(varchar(30), @euros, 1), ',', '|'), '.', ','), '|', '.')
想法:先把逗号换成东西,再把点换成逗号,再把东西"换回点.
Idea: first change comma to something, then change dot to comma, and then "something" back to dot.
这篇关于显示逗号而不是点作为小数分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:显示逗号而不是点作为小数分隔符
基础教程推荐
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
