title: T-SQL where clause case statement
body: <p>Need some small help with some SQL. I am using a <code>VARCHAR</code> value to determine in a case which logic to use in WHERE clause but I am having some issues writing this case statement.</p>
  
  <pre><code>where 
     (CASE WHEN @p_flag = 'ATA' 
              THEN (@p_start_ata IS NULL AND @p_end_ata IS NULL) OR (vso.poa_ata between @p_start_ata and @p_end_ata)
           ELSE (@p_start_atd IS NULL AND @p_end_atd IS NULL) OR (vso.pol_atd between @p_start_atd and @p_end_atd)
  )
  </code></pre>
  
  <blockquote>
    <p>Line 93 Incorrect syntax near the keyword 'IS'.</p>
  </blockquote>
  
  <p>Its probably a minor error but its frustrating me. Maybe there is a better way of writing this? Thanks!</p>