2

I have an XML column in one of my table. For example I have an Employee table with following fields:

Name (varhcar) | Address (XML)

The Address field is having values like

<Address>
<Street></Street>
<City></City>
</Address>

I have some n number of rows already in the table. Now I want to insert a new node - Country to all the rows in tha table. With default:

<Country>IND</Country>.

How can I write the query for this. I want all the existing data to be as it is with adding the country node to all the Address column XML.

1
  • 2
    To get your XML to display, you need to format it as code. I've done this for you... Commented Jun 15, 2010 at 8:49

2 Answers 2

3
update Employee set Address.modify('insert  <Country>IND</Country>
 as last into (/Address)[1]')
Sign up to request clarification or add additional context in comments.

Comments

2

Try this

SET @XMLDATA.modify(' insert <Country>IND</Country> as last into (Address[1]) ')

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.