[英]SQL Server 2008, convert float to string
I need to convert float field (sp.[Current]) to string.我需要将浮点字段 (sp.[Current]) 转换为字符串。 The part of the query is:
查询的部分是:
SELECT
cast(sp.CustID as varchar(10)) CustID,
cast(sp.Year as varchar(4)) Year,
convert(nvarchar(50), sp.[Current]) AS Potential,
sp.[Current] as Potential1
But after converting I get this result但转换后我得到这个结果
I get exponential notation of the number.我得到数字的指数符号。 How can I improve it?
我该如何改进?
你可以像下面这样尝试
CONVERT(numeric(16,0), CAST([Current] AS FLOAT))
Try this尝试这个
DECLARE @val float = 2000000.890
select convert(nvarchar(50),CAST(@val AS numeric(16,4)))
You can refer to this link How to use STR SQL SERVER as illustrated below您可以参考这个链接How to use STR SQL SERVER如下图所示
SELECT STR(float,25, 2)
Good Luck .祝你好运 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.