title: How to merge XML in T-SQL?
body: <p>It doesn't seem that any amount of reading the docs will help me.  Consider the simplified example:</p>
  
  <pre><code>declare @table1 table ( id int, parent xml )
  insert @table1 values( 1, '&lt;Root&gt;&lt;/Root&gt;' )
  declare @table2 table ( id int, guts xml )
  insert @table2 values( 1, '&lt;Guts&gt;hi mom!&lt;/Guts&gt;' )
  
  select t1.parent.query('')
  from @table1 t1 inner join @table2 t2 on t1.id = t2.id
  </code></pre>
  
  <p>What would be passed to the query function to generate this result?</p>
  
  <pre><code>&lt;Root&gt;&lt;Guts&gt;hi mom!&lt;/Guts&gt;&lt;/Root&gt;
  </code></pre>