title: Why this sql will cause type conversion error?
body: <pre><code>WITH tb_testl AS （
      SELECT 1 AS id ,'hehe' AS value 
      UNION ALL 
      SELECT 1 AS id, '1' AS value 
      UNION ALL 
      SELECT 2 AS id, '2' AS value 
      UNION ALL 
      SELECT 2 AS id, '2' AS value
  ), tb_test2 AS (
      SELECT CONVERT(INT , value) AS value FROM tb_testl WHERE id = 2 
  )
  SELECT * FROM tb_test2 WHERE value = 2;
  </code></pre>
  
  <p>this sql will cause error </p>
  
  <blockquote>
    <p>Conversion failed when converting the varchar value 'hehe' to data
    type int.</p>
  </blockquote>
  
  <p>but the table <code>tb_test2</code> dosen't have the value 'hehe' which is in the anthor table <code>tb_test1</code>. And I found that this sql will work well if I don't append the statement <code>WHERE value = 2;</code> .I've tried <code>ISNUMBERIC</code> function but it didn't work.   </p>
  
  <p>version:mssql2008 R2</p>