我有一个表(让我们称之为t),其中包含字段id(int)和XmlField(xml).
我尝试在一个查询中添加多个节点,但无论我尝试了什么,我都会遇到错误.
查询是:
update t
set XmlField.modify('insert <f1>value here</f1><f2>value there</f2> into (/xmldoc)')
Run Code Online (Sandbox Code Playgroud)
我收到错误:
XQuery [t.XmlField.modify()]:''之前的语法错误,''在'之后','之前'或'之后'''.
当我尝试只添加一个xml节点时,它正在工作(示例):
update t set XmlField.modify('insert <f1>value here</f1> into (/xmldoc)')
Run Code Online (Sandbox Code Playgroud)
当我尝试添加这样的嵌套节点时,它也正在工作:
update t set XmlField.modify('insert <f><f1>value here</f1><f2>value there</f2></f> into (/xmldoc)')
Run Code Online (Sandbox Code Playgroud)
有没有办法让它成真?
我有一个查询内部的一些子查询,我想添加一个求和查询来总结它们.
我怎样才能做到这一点?
例:
Id,
(SELECT COUNT(*) FROM table1 LEFT JOIN table2 on ...) as col1,
(SELECT COUNT(*) FROM table3 LEFT JOIN table4 on ...) as col2,
** Sum of both col1 and col2 here **
Run Code Online (Sandbox Code Playgroud)