title: Combine UPDATE with INNER JOIN and STUFF Function
body: <p>I am trying to use a stuff query with an UPDATE and INNER JOIN without success.
  I need to stuff the results of a query into one column/row and update another table with that result.</p>
  
  <p>My current code is this.</p>
  
  <pre><code>Update t1
  SET t1.col1 = t2.ordernotes 
  FROM db.dbo.table1 t1
  INNER JOIN 
      STUFF((
              (Select order_no, Notes As ordernotes
              FROM db.dbo.table2
              GROUP BY order_no
              ORDER BY TimeStamp
              FOR XML PATH('')
              ),1,1,'')
              As t2
  ON t2.order_no = t1.order_no
  </code></pre>
  
  <p>The query in the inner join returns the following result</p>
  
  <pre><code>Order_no | OrderNotes
  1234     | Note 1
  1234     | Note 2
  1234     | Note 3
  </code></pre>
  
  <p>The desired result is this and then updated into table 1</p>
  
  <pre><code>Order_no | OrderNotes
  1234     | Note 1, Note 2, Note 3
  </code></pre>