title: Add columns dynamically based on a condition in SQL
body: <p>I'm using SSMS 2012. Consider a table A with columns A, B, C. I would like to dynamically add a new column, D to this table based on a condition in one of the existing columns. How can this be achieved?</p>
  
  <p>Query looks like the following,
  select col1, col2 from #temptbl </p>
  
  <p>To this #temptbl, I would like to add a column, col3 and the value in col3 is based on a condition on col2.</p>