For the ones whohavethe same problem, here is aSQLscripttothe desiredXMLformat(variable,row/column)
USE <DATABASENAME>
;With CTE
AS
(
SELECT [ColumnA]
,[ColumnB]
,[ColumnC]
FROM TABEL
)
select [ColumnA] AS [@name],
(select [ColumnB] as [column],
null as tmp,
ColumnC as [column],
from CTE
where [ColumnA] = t.[ColumnA]
for xml path('row'),type) as [*]
from (select distinct [ColumnA] from CTE)t
for xml path('variable'),root('data')
In this script the variable is named by the value of ColumnA.
Regards,
Bart