title: Handle NULL when using substring function in where clause
body: <p>I have to check the contents of Col1 which has values like <code>somestring (someotherstring)</code> against Col2 (the <code>somestring</code> part)  and Col3 (the <code>someotherstring</code> part). Col2 is always 10 characters long. Col1 has NULL values.</p>
  
  <p>This is what I have right now:  </p>
  
  <pre><code>select * from MyTable
  where
  substring(Col1,1,10) != Col2
  OR substring(Col1,13,LEN(Col1)-13) != Col3
  </code></pre>
  
  <p>I'm getting the error:</p>
  
  <p><code>Invalid length parameter passed to the LEFT or SUBSTRING function.</code></p>
  
  <p>I'm guessing the null values in Col1 are my problem. I've tried ISNULL and COALESCE but it's still not working. I must be doing something wrong. How do I fix this?</p>