title: SQL Argument data type int is invalid for argument 1 of charindex function
body: <p>I'm trying to convert MySQL query to MsSql query but I'm having trouble. Here is my query:</p>
  
  <p>MySQL </p>
  
  <pre><code>SELECT *,
  (SELECT count(books.id)
     FROM books
     WHERE books.status = 1
       AND FIND_IN_SET(categories.id, books.multiple_category_id)) AS book_count
     FROM categories, books
     WHERE categories.parent_id=0
       AND categories.status=1 ;
  </code></pre>
  
  <p>SQL I've tried </p>
  
  <pre><code>SELECT *,
    (SELECT count(books.id)
     FROM books
     WHERE books.status = 1
       AND CHARINDEX(categories.id, books.multiple_category_id) &gt; 0) AS book_count
     FROM categories, books
     WHERE categories.parent_id=0
       AND categories.status=1 ;
  </code></pre>
  
  <p>The errors I'm getting are:</p>
  
  <pre><code>Argument data type int is invalid for argument 1 of charindex function.
  </code></pre>
  
  <p>For reference.
  <a href="http://sqlfiddle.com/#!3/4ed19/3" rel="noreferrer">http://sqlfiddle.com/#!3/4ed19/3</a></p>
  
  <p>does anyone have any ideas?
  Thanks in advance!</p>