I have a XML column as shown below:
<Root>
<Row>
<Rowid>1</Rowid>
<date>2013-05-06</date>
<Balance>1.0002E7</Balance>
</Row>
</Root>
When I query to get the balance, I get it as 1.0002E7
. But I want to get it like this: 10002000
.
How can I do it?
Can I make any changes so that the XML column itself is stored as I want it without scientific notation?
Best Answer
Specify
float
when fetching the value from the XML.To change the value in a XML column with decimals included you need to first extract the value as a
float
and write it back as annumeric
with the appropriate precision and scale.Something like this.
SQL Fiddle
The reason for the scientific notation is because it is the way SQL Server handles xs:float when using untyped XML.
From Type Casting Rules in XQuery