Hi there,
I have the following TSQL statement:
select
tblName "TblName",
structure "TblName/STRUCTURE",
sqlRetrieve "TblName/SQLRETRIEVE",
Identifier "TblName/IDENTIFIER",
'2' "TblName/OBJECTTYPE"
from
configTable
for xml path ('')
which outputs:
<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>
but I want to have this output (the element name :
<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>
Does anybody know how to achieve this with T-SQL?
Thanks
Daniel