我有一个xml字符串,我可以用
读取ID的值;WITH XMLNAMESPACES
('http://collaborate.com/svn/capabilities/tdp/ManageNetworkAndServiceDiagnosticsV4/' AS P,
'https://collaborate.com/svn/edm/tdp/Test' as p2)
Select @id = feed.xx.value('.','VARCHAR(50)')
From @smxml.nodes('/p:initiateTest/p2:Test/p2:id') feed(xx)
这设置了我修改的@ID变量,然后我想把它放回到表中。 我试过了
;WITH XMLNAMESPACES
('http://collaborate.com/svn/capabilities/tdp/ManageNetworkAndServiceDiagnosticsV4/' AS p,
'https://collaborate.com/svn/edm/tdp/Test' as p2)
UPDATE CT_GTCS_Temp_XML
SET xmlStartString.modify('replace value of (/p:initiateTest/p2:Test/p2:id with @New_Id)')
BUt我得到一个错误 XQuery [CT_GTCS_Temp_XML.xmlStartString.modify()]:")"是预期的。
答案 0 :(得分:0)
正如错误消息所示,您没有将右括号放在正确的位置。把它放在XQuery之后,而不是在with
子句之后:
.....
SET xmlStartString.modify('replace value of
(/p:initiateTest/p2:Test/p2:id/text())[1]
with sql:variable("@New_Id")')