0

我有 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>

如何在标签之间插入文本数据?

4

1 回答 1

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>
于 2013-06-05T20:30:17.560 回答