If you're using MS-SQL-S you can use
with CTE as (
select all your data ...
.... ... .... ...
FOR XML [strict | auto | PATH('foobar')], [TYPE], [ELEMENTS]
) as tagbaz
FOR XML PATH('root'), TYPE
Works like a charm with common table expressions + all select sub-queries and no FROM clause. Not the most efficient thing in the world, but it's nice and easy once you understand the FOR XML syntax. You'll have to be a sub-query guru to get the data exactly how you want it-
it can be an enormous hassle if your XML document is not structured in a hierarchical way. *slaps coworker*
I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;