title: Using IF / ELSE to determine a SELECT INTO statement
body: <p>I'm having some strange issues using IF / ELSE to determine which one or two SELECT statements to execute. The error message I'm getting when running the full statement is that my temporary table already exists, but that does not occur if I run two separate executions of two separate IF statements. </p>
  
  <p>Here is the code in SQL Server:</p>
  
  <pre><code>IF (select BusinessDayCount from Calendartbl) &lt;= 1
    BEGIN
      SELECT * into #temp1
      FROM PreviousMonthTbl
    END
  ELSE
    BEGIN
      SELECT * into #temp1
      FROM CurrentMonthTbl
    END
  </code></pre>