title: Pivot cateorical values into boolean columns SQL
body: <p>I'm looking to 'flatten' my dataset in order to facilitate data mining.
  Each categorical column should be changed to multiple Boolean columns.
  I have a column with categorical values, e.g.:</p>
  
  <pre><code> ID    col1
    1     A
    2     B
    3     A
  </code></pre>
  
  <p>I'm looking for a way to pivot this table, and have an aggregated function telling me whether this ID has value A or B:</p>
  
  <p>Result:</p>
  
  <pre><code> ID    col1A    col1B
    1     1        0
    2     0        1
    3     1        0
  </code></pre>
  
  <p>I tried using PIVOT but have no idea which aggregated function to use inside it.</p>
  
  <p>Also looked for answers in SF but couldn't find any...</p>
  
  <p>I'm using MS-SQL 2012.</p>
  
  <p>Any help would be appreciated!
  Omri</p>
  
  <p>EDIT:</p>
  
  <p>The number of categories in col1 is unknown, therefore the solution must be dynamic.
  Thanks :)</p>