title: SQL SERVER 2014 - Split String & Convert to INT
body: <p>I have a string</p>
  
  <p><code>1,2,3|5</code></p>
  
  <p>After Split with <code>|</code>  I have </p>
  
  <p><code>1,2,3</code>, <code>5</code></p>
  
  <p>Now I want to convert <code>1,2,3</code> to <code>INT</code>. How can I achieve this?</p>
  
  <p>Following is my query</p>
  
  <pre><code>Declare @tmpReferContentRule = "1,2,3|5"
  SELECT items 
  FROM splitbystring(@tmpReferContentRule,'|') 
  WHERE id = 1
  </code></pre>
  
  <p>I want to use it in </p>
  
  <pre><code>SELECT name 
  FROM tmptable 
  WHERE id in(SELECT items FROM splitbystring(@tmpReferContentRule,'|'))
  </code></pre>
  
  <p><sub><code>id</code> is type of integer</sub></p>
  
  <p>The above query throws an error </p>
  
  <blockquote>
    <p>1,2,3 could not be converted to int.</p>
  </blockquote>
  
  <p>Please suggest a solution.</p>