title: SQL to Make XML Path list Columns
body: <p>I have the following SQL Server query which cranks out a comma delimited list into one field. </p>
  
  <p>Result looks like this <code>2003, 9083, 4567, 3214</code> </p>
  
  <p>Question: What would be the best way (SQL syntax) to put this into columns?</p>
  
  <p>Meaning, I need these to show up as 1 column for "2003", 1 column for "9083" 1 column, for "4567" ..etc.<br>
  Obviously the number of columns would be dynamic based on the policy ID I give it . Any idea would be most appreciated. </p>
  
  <p>My query is below .</p>
  
  <pre><code>SELECT DISTINCT x.ClassCode + ', '
  FROM PremByClass x
  WHERE x.PolicyId = 1673885
  FOR XML PATH('')
  </code></pre>