title: IN only matches on first value when using STRING_SPLIT
body: <p>I have a varchar of comma separated values. I am attempting to check if a value is in the comma separated list. </p>
  
  <p>For instance, if the varchar is 'AAA, BBB, CCC', checking for 'BBB' should return true. </p>
  
  <p>I am using STRING_SPLIT to parse the commas separated list, but matching is only working as I expect on the first value:</p>
  
  <pre><code>DECLARE @List VARCHAR(100) = 'AAA, BBB, CCC'
  
  SELECT
  CASE    
      WHEN 'AAA' IN (SELECT VALUE FROM STRING_SPLIT(@List, ',')) THEN 'true'
      ELSE 'false'
  END
  --selects true
  
  
  SELECT
  CASE    
      WHEN 'BBB' IN (SELECT VALUE FROM STRING_SPLIT(@List, ',')) THEN 'true'
      ELSE 'false'
  END
  --selects false
  </code></pre>
  
  <p>As you can see from this <a href="https://i.stack.imgur.com/gdgIF.png" rel="nofollow">Screenshot</a>, STRING_SPLIT is splitting all of the values as expected. Why is IN only checking for the first one?</p>