title: SQL Server convert varchar string to int
body: <p>Hi all I have the following stored procedure </p>
  
  <pre><code>SELECT DISTINCT QuestionId, AnswerId, COUNT(AnswerId) AS Cntr,
      (SELECT     COUNT(AnswerId) AS ttl
       FROM          QUserAnswers
       WHERE      (QuestionId = QUAM.QuestionId)) AS TtlCnt
  FROM         QUserAnswers AS QUAM
  WHERE     (QuestionId IN (@QuestionIdIn))
  GROUP BY QuestionId, AnswerId
  ORDER BY QuestionId
  </code></pre>
  
  <p>which I pass in <code>@QuestionIdI</code> in the format '<code>1,2,3,4,5'</code> however, its throwing the error Conversion failed when converting the varchar value <code>'1,2,3,4,5,6'</code> to data type <code>int</code>.</p>
  
  <p>Can anyone give me some pointers to sort it out </p>