title: SQL Server 2005 - If condition with union
body: <p>I have a SP that has the following algorithm.</p>
  
  <pre><code>IF &lt;SomeCondition&gt;
  BEGIN
    SELECT * FROM TABLE1
  END
  ELSE
  BEGIN
    SELECT * FROM TABLE2
  END
  --Union the above with the query below
  UNION
    SELECT * FROM TABLE3
  </code></pre>
  
  <p>The recordset returned is EXACTLY the same. I need to do a UNION of that resultset and another query.</p>
  
  <p>Is there a way to do this without having to use a temp table?</p>