title: Can STUFF function return NULL values?
body: <p>I'm looking at the following link:</p>
  
  <p><a href="https://stackoverflow.com/questions/2046037/can-i-comma-delimit-multiple-rows-into-one-column?noredirect=1&amp;lq=1">Can I Comma Delimit Multiple Rows Into One Column?</a></p>
  
  <p>The query used in the solution is exactly what I need, but also need to return NULL values.</p>
  
  <pre><code>SELECT t.TicketID,
     STUFF(ISNULL((SELECT ', ' + x.Person
              FROM @Tickets x
             WHERE x.TicketID = t.TicketID
          GROUP BY x.Person
           FOR XML PATH (''), TYPE).value('.','VARCHAR(max)'), ''), 1, 2, '') [No Preceeding Comma]
  FROM @Tickets t
  GROUP BY t.TicketID
  </code></pre>
  
  <p>This works great if each [TicketID] has an associated [Person].  </p>
  
  <p>But if the Person is NULL, for the TicketID, I need to return just the TicketID and have the Person show as NULL or blank. I'm having trouble removing the ISNULL cleanly.</p>
  
  <p>From this:</p>
  
  <pre><code>[TicketID], [Person]
   T0001       Alice
   T0001       Bob
   T0002       Catherine
   T0002       Doug
   T0003       Elaine
   T0004       NULL
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>[TicketID], [Person]
   T0001       Alice, Bob
   T0002       Catherine, Doug
   T0003       Elaine
   T0004       NULL
  </code></pre>