title: Name XML result column of TSQL "for xml explicit"?
body: <p>I have a query that uses <code>for xml explit</code> to return XML result.</p>
  
  <p>select ...
   from ...
   order by [BatchType!1!TypeName], [FormType!2!TypeName], Tag, Parent
   for xml explicit, root('ClientImages')</p>
  
  <p>But the name of resultant column name is something as cryptic as</p>
  
  <p><img src="https://farm3.static.flickr.com/2578/4011608808_30c0b16e35_o.png" alt="alt text"></p>
  
  <p><strong>Is there a way to change the column name?</strong></p>
  
  <hr>
  
  <p><strong>[ANSWER]</strong>
  I had a several nested <code>WITH</code> statements so I have saved the result of query without applying <code>FOR XML EXPLICIT</code> into a temp table <code>@xmlTable</code> and then set the XML EXPLICIT result to an XML then returned it.</p>
  
  <pre><code>declare @xmlResult xml
  set @xmlResult =(   
      select  * 
      from    @xmlTable
      for xml explicit, root('ClientImages'))
  
  select  @xmlResult as XmlResult
  </code></pre>