I'll assume your query produces a single record with the XML data type, and as the UNION ALL expects data types to match, and that my idea assumed a different scenario, this won't quite work as written, however..
You could use your query as a subquery as follows:
SELECT '<?xml version="1.0" encoding="iso8859-1"?>' +
(
SELECT doc.col1, doc.col2, doc.col3
FROM TestTable AS doc
FOR XML PATH ('doc')
)
Let me know if that works for you...
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)