XML存储可以在<Address>
下拥有零个或多个<Addresses>
个节点
需要查询才能删除<Address>
<AddressLine> = '2 Church Lane'
个节点
启动XML:
declare @t table (storage xml);
insert into @t (storage)
select '<Person>
<Fullname />
<Surname>Smith</Surname>
<FirstName>John</FirstName>
<Addresses>
<Address>
<AddressLine>1 Church Lane</AddressLine>
</Address>
<Address>
<AddressLine>2 Church Lane</AddressLine>
</Address>
<Address>
<AddressLine>3 Church Lane</AddressLine>
</Address>
</Addresses>
</Person>';
产生的XML:
<Person>
<Fullname />
<Surname>Smith</Surname>
<FirstName>John</FirstName>
<Addresses>
<Address>
<AddressLine>1 Church Lane</AddressLine>
</Address>
<Address>
<AddressLine>3 Church Lane</AddressLine>
</Address>
</Addresses>
</Person>
答案 0 :(得分:5)
找到它:
update @t
SET storage.modify('
delete (/Person/Addresses/Address[AddressLine = "2 Church Lane"])
')