5

I want to change element name with following statement:

SET @myDoc.modify('replace value of (/CustomerInfo)[1] with "Customer"')   

from
<CustomerInfo>
    <ID>1</ID>
</CustomerInfo>
to
<Customer>
    <ID>1</ID>
</Customer>
But failed. So how can i change it just in sql ?

3 Answers 3

2
+100

I tried following sql:
select @myDoc=(
select @myDoc.query('/CustomerInfo/node()')
for xml raw('Customer'),type)
I guess it solve your question.

Sign up to request clarification or add additional context in comments.

Comments

1

I think you need to select the values with .query or .nodes into a resultset that will render into the XML you want using FOR XML

Comments

0

I have a non-grace method:
Convert xml to varchar, then replace it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.