title: How do I place the values in one column into a comma-delimited variable in SQL Server?
body: <p>I have a table with values that I would like to use as column names in a dynamic PIVOT query. As such, I need to put the values into a comma-delimited string (and then into a variable). </p>
  
  <p>In other words, I have a table @ColumnData like this:</p>
  
  <pre><code>ID      Title
  1       Income 
  2       Rent 
  3       Utilities   
  4       Childcare
  </code></pre>
  
  <p>And I need a the column "Title" in this form:</p>
  
  <pre><code>@Variable = [Income],[Rent],[Utilities],[Childcare]
  </code></pre>