title: Ignoring a NULL parameter in T-SQL
body: <p>I want to be able to pass in a list of parameters, and ignore the ones which are NULL. So that the query is in effect pretending that the filter isn't there and ignoring it. </p>
  
  <p>I was doing it like this:</p>
  
  <pre><code>(@thing IS NULL or Thing=@thing) 
  </code></pre>
  
  <p>Is this right, and if so, would it perform badly? It's seems to be a lot slower than constructing the SQL separately.</p>
  
  <p>What's the optimal way to do this?</p>
  
  <p>FIXED! See Marc Gravell's answer. In summary using IS NULL many times is a <em>big</em> performance hit. </p>