我有SQL
SELECT '' AS "dfn", CCFKeyType AS "dfn/b", GroupID AS "dfn/var", ID AS "dfn/code"
FROM (
...
) A
FOR XML PATH('')
它生成
<dfn>
<b>cid</b>
<var>0115</var>
<code>EXS</code>
</dfn>
我想生成:
<dfn>
<b>cid</b>
(<var>0115</var>):
<code>EXS</code>
</dfn>
如何在标签之间插入文本数据?
答案 0 :(得分:1)
SELECT '' AS "dfn" ,
'cid' AS "dfn/b" ,
'(' AS "dfn" ,
'0115' AS "dfn/var",
'):' AS "dfn" ,
'EXS' AS "dfn/code"
FOR XML PATH('')
输出:
<dfn>
<b>cid</b>
(<var>0115</var>):
<code>EXS</code>
</dfn>