title: SQL ISNULL not working
body: <p>I'm trying to display <code>00001</code> when the query result is null but the query still return null. I don't know whats wrong with my query.</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>Assuming <code>OBRNo</code> is <code>123-5678-10-13-1619</code> means <code>LEN(a.OBRNo) is 19</code></p>
  
  <pre><code>SELECT TOP 1 CASE WHEN RIGHT(a.OBRNo, 5) = NULL THEN '00001' ELSE a.OBRNo 
  END as CaseWhen, 
  ISNULL(a.OBRNo, '00001') as ISNULL,
  RIGHT(OBRNo, 5) as OrderBy
  FROM tbl_T_BMSCurrentControl as a
  WHERE LEN(a.OBRNo) = 20 and a.ActionCode = 1
  ORDER BY OrderBy DESC
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NClHG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NClHG.png" alt="enter image description here"></a></p>