SQL UNION FOR XML name output column SQL UNION FOR XML name output column sql-server sql-server

SQL UNION FOR XML name output column


Wrap your 2 selects on a single one like so:

select (    select id, name from (        select id, name         from xmltest         UNION        select id, name         from xmltest     ) A    FOR XML PATH ('AccountDetails'), root ('Root')) As XmlOutput