title: Performance issue joining a list into one column (single comma separated value)
body: <p>I want to join a column that has multiple values, and join them as comma separated list values into a single field. The SQL query works, however I think I run into performance issues.</p>
  
  <p>After 30 minutes of loading my SQL code it gives timeout problems: DataSource.Error: Microsoft SQL: Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.</p>
  
  <p>Whenever I select top 1000 rows, it still loads for an entire minute.</p>
  
  <p>The LEDGERTRANS.TXT is a string, and also with MAX() surrounding it, it gives me a timeout.</p>
  
  <p>MRPRJPROJTRANSPOSTING has 2,5M rows
  LEDGERTRANS +/- 5M rows, though I only join what I need from it.</p>
  
  <p>The following code is what I use:</p>
  
  <pre><code>SELECT 
  MRPRJPROJTRANSPOSTING.VOUCHER,
  [Factuuromschrijving(en)] = STUFF(
      (SELECT ',' + LEDGERTRANS.TXT 
          FROM LEDGERTRANS
          WHERE LEDGERTRANS.VOUCHER = MRPRJPROJTRANSPOSTING.VOUCHER 
  AND LEDGERTRANS.DATAAREAID = MRPRJPROJTRANSPOSTING.DATAAREAID FOR 
  XML PATH (''))
          , 1, 1, '' )
  FROM MRPRJPROJTRANSPOSTING
  </code></pre>
  
  <p>Is there maybe another way to make a similar join?</p>
  
  <p>Kind regards,
  Igor</p>