2013-05-13 15 views

Odpowiedz

7

Ponieważ istnieje nazw XML (xmlns:dev="http://www.w3.org/2001/XMLSchema") w dokumencie XML, trzeba inlcude że w swoim oświadczeniu UPDATE!

Spróbuj tego:

;WITH XMLNAMESPACES(DEFAULT 'http://www.w3.org/2001/XMLSchema') 
UPDATE XmlTable 
SET XmlDocument.modify('replace value of (/Doc/@Settings)[1] with "NewTest"') 
WHERE XmlId = 1 
3

Należy zadeklarować nazw w swojej składni aktualizacji .Try składni poniżej

Declare @Sample table 
(xmlCol xml) 

Insert into @Sample 
values 
('<dev:Doc xmlns:dev="http://www.w3.org/2001/XMLSchema" 
         SchemaVersion="0.1" Settings="Testing" Ttile="Ordering"> 
     <Person id="1"> 
      <FirstName>Name</FirstName> 
     </Person> 
     </dev:Doc>') 
Select * from @Sample 
Update @Sample 
SET xmlCol.modify(
        'declare namespace ns="http://www.w3.org/2001/XMLSchema"; 
        replace value of (/ns:Doc/@Settings)[1] 
        with "NewTest"') 

Select * from @Sample