DECLARE @Data XMLSET @Data = (SELECT * FROM dbo.yourFunctionName() FOR XML RAW(''Row''),ROOT(''Root''))
<Root> <Row Namel="ABitSmart" Age="27" Gender="Male" /></Root>
-- converting a temporary table to XML formatDECLARE @Data XMLSet @Data = (Select * from #tempTable For XML RAW('Row'),ROOT('Root'))
-- converting an in-memory table to XML formatDECLARE @Data XMLSet @Data = (Select * from @tempTable For XML RAW('Row'),ROOT('Root'))