• Very concise article.  I spent a couple days figuring this out.  Why is there nothing in BOL as simple as this? 

    You might note that to assign the results of the xml-generating query to a variable declared as XML, you need to surround the query in parentheses.

    declare @xmlparm xml

    select @xmlparm = (select orderid from order for xml auto, type)