您可以使用STR
而不是CONVERT
. STR
允许指定小数点右侧的小数位数。
DECLARE @m FLOAT=213456789.55;
SELECT
@m AS [Float]
,CONVERT(VARCHAR(100),@m,0) AS Convert0
,CONVERT(VARCHAR(100),@m,1) AS Convert1
,CONVERT(VARCHAR(100),@m,2) AS Convert2
,LTRIM(STR(@m, 20, 2)) AS [Str]
结果(SQL Server 2008)
+--------------+--------------+----------------+------------------------+--------------+
| Float | Convert0 | Convert1 | Convert2 | Str |
+--------------+--------------+----------------+------------------------+--------------+
| 213456789.55 | 2.13457e+008 | 2.1345679e+008 | 2.134567895500000e+008 | 213456789.55 |
+--------------+--------------+----------------+------------------------+--------------+
CONVERT
总是对float
类型使用科学记数法。