Impossible d'insert un nouveau noeud à l'aide de l'insertion (XML DML)

J'essaie d'insert un noeud en XML en utilisant l'insertion XML (XML DML).

Le XML ressemble à ceci:

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Worksheet xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" ss:Name="1"> <Table xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Row xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">Audit ID</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">Audit Subcategory ID</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">1</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">ObjectID</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">ObjectTypeID</Data> </Cell> </Row> <Row xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">55406</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">3</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">1</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">6078</Data> </Cell> <Cell xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <Data ss:Type="Ssortingng">1</Data> </Cell> </Row> </Table> </Worksheet> </Workbook> 

J'essaie d'insert un noeud en utilisant le code ci-dessous:

 SET @xml.modify('insert <Maintenance>111111111111111</Maintenance> into (/Workbook)[1]'); 

puis j'affiche datatables en utilisant

  Select @xml; 

Le problème est que le nouveau noeud ne s'affiche pas. J'essaie de modifier le XML en utilisant

 SET @xml.modify('insert <Maintenance>111111111111111</Maintenance> into (/Workbook/Worksheet)[1]'); 

Mais cela n'introduit aucun noeud.

Quelqu'un peut-il suggérer ce que je peux faire de mal?

On dirait que l'espace de noms par défaut doit être utilisé ici lors de l'insertion. Essaye ça.

 set @xml.modify(' declare namespace ns="urn:schemas-microsoft-com:office:spreadsheet"; insert <ns:Maintenance>111111111111111</ns:Maintenance> into (/ns:Workbook)[1]'); select @xml 

Cela a fonctionné les gars ..

  SET @xml.modify(' declare default element namespace "urn:schemas-microsoft-com:office:spreadsheet"; declare namespace ss="urn:schemas-microsoft-com:office:spreadsheet" ; declare namespace x="urn:schemas-microsoft-com:office:excel"; insert sql:variable("@xmlStyle") as first into (/Workbook)[1]') 

Je devais déclarer tous les namespaces qui étaient utilisés dans le XML. Le @xmlStyle est de type XML et contient le fragment de XML que je veux inclure en tant que noeud.

 @xmlStyle AS XML