title: Only if in where clause (SQL Server)
body: <p>I need to know how to do this:</p>
  
  <pre><code>WHERE (if @date is not null) date = @Date
  </code></pre>
  
  <p>It's only one condition to do if @date is not null else there is no condition to do. I read something like this </p>
  
  <pre><code>WHERE date = IIF (@Date IS NOT NULL, @date , )
  </code></pre>
  
  <p>But it doesn't work for this case.</p>
  
  <p>Thanks!</p>