title: SQL Server + Select WHERE IN comma delimited string
body: <p>I am trying to select records where the Id exists in a comma delimited string but the query below doesn't return any results:   </p>
  
  <pre><code>  SELECT * FROM [SellPost] WHERE CAST([AutoId] AS nchar(100)) 
     IN (SELECT [SellPostId] FROM [SellPostViewHistory]) -- SellPostId contains the delimited string 
  </code></pre>
  
  <p>The statement 'SELECT [SellPostId] FROM [SellPostViewHistory]' will return 19,20,21 and if I replace the query with </p>
  
  <pre><code>   SELECT * FROM [SellPost] WHERE CAST([AutoId] AS nchar(100)) 
     IN (19,20,21) 
  </code></pre>
  
  <p>it works. Can someone please kindly advice. Thanks.</p>