本文介绍了当以XML输出时,SQL“浮动"数据类型导致不希望的浮动结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您可以简单地尝试:table1:具有类型为"float"的column1代替
You can try simply:table1: has a column1 of type 'float' instead of
SELECT column1 from Table1;
给出表中所示的值.
SELECT column1 from Table1;
gives values as seen in table.
说这将返回15.1
但是,如果您尝试
Select column1 from Table1
FOR XML PATH('Table1'), Root('SomeRoot'), TYPE
返回:1.510000000000000e + 001
returns: 1.510000000000000e+001
有人看到过这个,如何解决?在此先感谢:)
Has anyone seen this, and how was this fixed?thanks in advance :)
推荐答案
这是使用浮点数时得到的.您可以尝试以下操作:
This is what you get when you work with floating point numbers. You can try this though:
SELECT CONVERT(varchar(100), CAST(column1 AS decimal(38,2)))
您只需要调整小数位数的精度即可满足您的需求.
you will just need to adjust the precision on the decimal to fit your needs.
这篇关于当以XML输出时,SQL“浮动"数据类型导致不希望的浮动结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!