title: What is a simple and efficient way to find rows with time-interval overlaps in SQL?
body: <p>I have two tables, both with start time and end time fields. I need to find, for each row in the first table, all of the rows in the second table where the time intervals intersect.</p>
  
  <p>For example:</p>
  
  <pre><code>           &lt;-----row 1 interval-------&gt;
  &lt;---find this--&gt; &lt;--and this--&gt; &lt;--and this--&gt;
  </code></pre>
  
  <p>Please phrase your answer in the form of a SQL <code>WHERE</code>-clause, AND consider the case where the end time in the second table may be <code>NULL</code>.</p>
  
  <p>Target platform is SQL Server 2005, but solutions from other platforms may be of interest also.</p>