title: SQL And NULL Values in where clause
body: <p>So I have a simple query that returns a listing of products</p>
  
  <pre><code>SELECT     Model, CategoryID
  FROM         Products
  WHERE     (Model = '010-00749-01') 
  </code></pre>
  
  <p>This returns </p>
  
  <pre><code>010-00749-01    00000000-0000-0000-0000-000000000000
  010-00749-01    NULL
  </code></pre>
  
  <p>Which is correct, so I wanted only the products whose CategoryID is not '00000000-0000-0000-0000-000000000000' so I have </p>
  
  <pre><code>SELECT     Model, CategoryID
  FROM         Products
  WHERE     (Model = '010-00749-01') 
  AND (CategoryID &lt;&gt; '00000000-0000-0000-0000-000000000000') 
  </code></pre>
  
  <p>But this returns no result. So I changed the query to</p>
  
  <pre><code>SELECT     Model, CategoryID
  FROM         Products
  WHERE     (Model = '010-00749-01') 
  AND ((CategoryID &lt;&gt; '00000000-0000-0000-0000-000000000000') OR  (CategoryID  IS NULL))
  </code></pre>
  
  <p>Which returns expected result</p>
  
  <pre><code>010-00749-01    NULL
  </code></pre>
  
  <p>Can someone explain this behavior to me?
  MS SQL Server 2008</p>