我有以下 TSQL 语句:
select
tblName "TblName",
structure "TblName/STRUCTURE",
sqlRetrieve "TblName/SQLRETRIEVE",
Identifier "TblName/IDENTIFIER",
'2' "TblName/OBJECTTYPE"
from
configTable
for xml path ('')
输出:
<TblName>PD_CODE_PRODUCTS
<STRUCTURE>PD_CODE_PRODUCTS</STRUCTURE>
<SQLRETRIEVE>BATCHSP</SQLRETRIEVE>
<IDENTIFIER>DATA_OWNER</IDENTIFIER>
<OBJECTTYPE>2</OBJECTTYPE>
</TblName>
<TblName>PD_two
<STRUCTURE>PD_CODE_PRODUCTS</STRUCTURE>
<SQLRETRIEVE>BATCHSP</SQLRETRIEVE>
<IDENTIFIER>DATA_OWNER</IDENTIFIER>
<OBJECTTYPE>2</OBJECTTYPE>
</TblName>
但我想要这个输出(元素名称:
<PD_CODE_PRODUCTS>
<STRUCTURE>PD_CODE_PRODUCTS</STRUCTURE>
<SQLRETRIEVE>BATCHSP</SQLRETRIEVE>
<IDENTIFIER>DATA_OWNER</IDENTIFIER>
<OBJECTTYPE>2</OBJECTTYPE>
</PD_CODE_PRODUCTS>
<PD_two>
<STRUCTURE>PD_CODE_PRODUCTS</STRUCTURE>
<SQLRETRIEVE>BATCHSP</SQLRETRIEVE>
<IDENTIFIER>DATA_OWNER</IDENTIFIER>
<OBJECTTYPE>2</OBJECTTYPE>
</PD_two>
有人知道如何使用 T-SQL 实现这一目标吗?
谢谢
丹尼尔