title: IF Inside WHERE with stored procedure
body: <p>I have a WHERE statement that looks like this:</p>
  
  <pre><code>WHERE 
      ((@Value1 IS NULL AND [value1_id] IS NULL) OR [value1_id] = ISNULL(@Value1, [value1_id]))
      AND
      ((@Value2 IS NULL AND [value2_id] IS NULL) OR [value2_id] = ISNULL(@Value2, [value2_id]))
      AND
      ((@Value3 IS NULL AND [value3_id] IS NULL) OR [value3_id] = ISNULL(@Value3, [value3_id]))
      AND
      ((@Value4 IS NULL AND [value4_id] IS NULL) OR [value4_id] = ISNULL(@Value4, [value4_id]))
      AND
      ((@Value5 IS NULL AND [value5_id] IS NULL) OR [value5_id] = ISNULL(@Value5, [value5_id]))
      AND 
      ((@Value6 IS NULL AND [value6_id] IS NULL) OR [value6_id] = ISNULL(@Value5, [value6_id]))
  </code></pre>
  
  <p>I need to add some conditional logic inside of the WHERE so I can do special things with Value5 and Value6. Basically, if Value5, Value6, or another value is null, I want to use the Value 5 and Value 6 lines as is. If all three values aren't NULL, I need to run some calculations on the values.</p>
  
  <p>Any ideas on what the best action would be?</p>