2010-06-15 73 views
2

我的表中有一個XML列。例如我有一個僱員表與以下字段:修改SQL XML列

Name (varhcar) | Address (XML)

地址字段由具有像

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

值I具有的行一些n個已經在表中。 現在我想插入一個新的節點 - 國家表中的所有行。使用默認值:

<Country>IND</Country>. 

我該如何爲此編寫查詢。我希望現有的所有數據都能像將國家節點添加到所有地址列XML一樣。

+2

爲了讓您的XML顯示,你需要把它格式化爲代碼。我已經爲你做了這個... – 2010-06-15 08:49:13

+0

謝謝大衛! – Chinjoo 2010-06-15 08:52:10

回答

2

試試這個

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