title: Comparing dates if one date is NULL
body: <p>Why do I get different result from these two samples?</p>
  <pre><code>DECLARE @validFrom DATE
  DECLARE @validTo DATE
  
  SET @validFrom = GETDATE()
  SET @validTo = NULL
  
  IF (@validFrom = @validTo)
     PRINT 'same'
  ELSE
     PRINT 'not same'
  </code></pre>
  <p>Result: not same</p>
  <p>But this code does not work:</p>
  <pre><code>DECLARE @validFrom DATE
  DECLARE @validTo DATE
  
  SET @validFrom = GETDATE()
  SET @validTo = NULL
  
  IF (@validFrom &lt;&gt; @validTo)
      PRINT 'not same'
  ELSE
      PRINT 'same'
  </code></pre>
  <p>Result: same</p>