Hello,
is it possible to combine different XML trees as nested into a new one? The XMLs are created using stored procedures in SQL Server. I'm giving you below the code for one of the tables.
SELECT
'TEST' AS [table/@t],
(
SELECT
GroupName as [@g],
(SELECT
Code [@val],
(SELECT
ColumnName as [col/@c],
CASE name
WHEN 'A' THEN A
WHEN 'B' THEN B
WHEN 'C' THEN C
WHEN 'D' THEN D
WHEN 'E' THEN E
WHEN 'F' THEN F
WHEN 'G' THEN G
WHEN 'H' THEN H
END AS [col/value]
FROM sys.columns
CROSS JOIN TEST c1
INNER JOIN COLUMN_GROUP r1
ON sys.columns.name=r1.columnname
WHERE object_id = OBJECT_ID('TEST')
and r1.GroupName=r2.GroupName and c1.Id=c2.Id
ORDER BY column_id
FOR XML PATH(''),TYPE)
FROM TEST c2
FOR XML PATH('u'),TYPE
)
FROM sys.columns
CROSS JOIN TEST c3
INNER JOIN COLUMN_GROUP r2
ON sys.columns.name=r2.columnname
WHERE object_id = OBJECT_ID('TEST')
GROUP BY GroupName
FOR XML PATH('group'),TYPE
)AS [table]
FOR XML PATH('')
Here's is how I need the result to be:
<f n=**value**>
<table t='TEST'>
.....
</table>
<table t='TEST2'>
....
</table>
<table t='TEST3'>
.....
</table>
....
</f>
Any kind of help would be appreciated.
Thank you in advance.