title: SQL : Error converting data type varchar to numeric
body: <p>I have met a very strange problem. There are two sql queries:</p>
  
  <p>Q1:</p>
  
  <pre><code>SELECT *
  FROM tbl_1
  WHERE ID IN (SELECT TargetID
               FROM tbl_2 
               WHERE PeopleID = 'AAA') 
  AND ID = 49
  </code></pre>
  
  <p>Q2:</p>
  
  <pre><code>SELECT *
  FROM tbl_1
  WHERE ID IN (SELECT TargetID
               FROM tbl_2 
               WHERE PeopleID = 'BBB') 
  AND ID = 49
  </code></pre>
  
  <p>We could find these two queries are identical except for <strong>PeopleID</strong>. But their result were very difference. For Q1, we got "<strong>Error converting data type varchar to numeric</strong>"; And for Q2, it ran well. I was confused!</p>
  
  <p>There are some infomation that may be useful.</p>
  
  <pre><code>tbl_1  ID       numeric(18,0) not null
  
  tbl_2  TargetID varchar(50)   not null
  </code></pre>
  
  <p>and every <strong>TargetID</strong> in Q1 or Q2 could pass the <code>IsNumeric</code> test (namely, <code>IsNumeric(TargetID) = 1</code>)</p>
  
  <p>another information: if we comment the line <code>AND ID = 49</code> and every query run well</p>
  
  <p>thx for your help</p>