For xml raw, root(''), elements


declare @xml_data xml, @xml_header xml

set @xml_data = (select *
from #TEMP_OUTPUT
where indent != 0
for xml raw, root('Rows'), elements)

--select @xml_data

set @xml_header = (select alias
from dbo.IMS_VIEW_COLUMN_TABLE
where view_id = @p_viewid and ISACTIVE = 1
order by sort_order
for xml raw, root('Header'))