I have an existing XML column that I'd like to append a node to, but the node is being added with an unwanted namespace.
DECLARE @x XML =
'<Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="abc">
<Setting key="display" display="ABC" group="service" enabled="true">
<Value xsi:type="xsd:string">ABC</Value>
</Setting>
</Test>'
CREATE TABLE #C ( x XML )
INSERT INTO #C
SELECT @X
declare @name varchar(50) = 'ABC'
UPDATE #C
SET X.modify('insert <Setting key="about" display="About" group="service" enabled="true">
<Value xsi:type="xsd:string">string of text about {sql:variable("@name")} here.</Value>
</Setting> as last into (/Test[1])')
select * from #C
results in the new setting being added as...
<Setting key="about" display="About" group="service" enabled="true">
<Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">string of text about ABC here.</Value>
</Setting>
but what I really want is
<Setting key="about" display="About" group="service" enabled="true">
<Value xsi:type="xsd:string">string of text about ABC here.</Value>
</Setting>