Ich habe eine Tabelle mit XML-Daten. Aus irgendeinem Grund haben bestimmte Felder im XML-Wert inkonsistente Daten. Ich muss es entsprechend modifizieren. In der unteren Vorlage können wir für das Feld txtCapacity sehen, dass der Wert außerhalb des Bereichs liegt. Ich muss es in das richtige Format umwandeln es als Float zu machen?Ändern Sie den Wert in Xml mit dem richtigen Format
Below is the table structure
Table XML_Capacity
(RID int,
xml_detail xml
)
Xml template
<Form>
<LT004>
<Field>
<id>txtDate</id>
<value>3/14/2017</value>
<tag />
<visible>true</visible>
<description>Install Date:</description>
<comment />
</Field>
<Field>
<id>txtAge</id>
<value />
<tag />
<visible>true</visible>
<description>Age:</description>
<comment />
</Field>
<Field>
<id>txtCapacity</id>
**<value>4.000000000000000e+003</value>**
<tag />
<visible>true</visible>
<description> Capacity:</description>
<comment />
</Field>
<Field>
<id>Status</id>
<value>Upgrade Repair Not Marked</value>
<tag />
<visible>true</visible>
<description>Status</description>
<comment />
</Field>
<Field>
<id>RemovedDate</id>
<value />
<tag />
<visible>false</visible>
<description>Date:</description>
<comment />
</Field>
I used the below code to modify but it is not allowing me to use convert
function inside that update statement
UPDATE XML_Capacity
SET xml_detail.modify('replace value of (/Form/L004/Field/text())[16] with (/FormValue/L004/Field/text())[16]')
Where
xml_detail.value('(/Form/L004/Field/node())[15]', 'varchar(45)') = 'txtCapacity'
Danke, es hat gut funktioniert. –