Monday, 15 September 2014

Updating an sql xml field which has xmlnamespaces



I have an xml string which I can read the value of the ID out with



;WITH XMLNAMESPACES
('http://ift.tt/1y6YhfR' AS P,
'http://ift.tt/1qWJiyz' as p2)
Select @id = feed.xx.value('.','VARCHAR(50)')
From @smxml.nodes('/p:initiateTest/p2:Test/p2:id') feed(xx)


This sets the @ID variable, which I amend, and then I want to place it back into the table. I have tried



;WITH XMLNAMESPACES
('http://ift.tt/1y6YhfR' AS p,
'http://ift.tt/1qWJiyz' as p2)
UPDATE CT_GTCS_Temp_XML
SET xmlStartString.modify('replace value of (/p:initiateTest/p2:Test/p2:id with @New_Id)')


BUt I get an error of XQuery [CT_GTCS_Temp_XML.xmlStartString.modify()]: ")" was expected.


No comments:

Post a Comment