title: How to allow temporary tables to accept null values
body: <p>If you create temp tables using "insert into" in SQL Server it uses the first insert to determine whether a column accepts null value or not. if the first insert has null value the column become nullable otherwise it will be non-nullable. </p>
  
  <p>Is there a way to create temp tables using "insert into" to accept null values?</p>
  
  <p>Example</p>
  
  <p>This works without any problem</p>
  
  <pre><code>Select 'one' as a , null as b
  into #temp
  
  insert into #temp
  Select 'two' as a , 500 as b
  </code></pre>
  
  <p>However this throws "Cannot insert the value NULL into column 'b'"</p>
  
  <pre><code>Select 'one' as a , 500 as b
  into #temp
  
  insert into #temp
  Select 'two' as a , null as b
  </code></pre>
  
  <p>I know I could do <code>create Table</code> or <code>alter column</code> statement but I want to do it without rewriting hundreds of the existing queries.</p>