2013-06-05 118 views
0

我有SQLXML與標籤之間的內容

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> 

如何文本數據標籤之間inseted?

回答

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>