title: SQL Join table-valued function with table where table field is a function input
body: <p>I have a table-valued function called fn_SplitCommaSep, which comma-separates a text field (from 'a, b, c' to 3 rows: a b c)</p>
  
  <p>How can I join this to a table, taking a table column as an input?</p>
  
  <p>For the purpose of this, say the table MyTable has 2 columns, Id and TextWithCommas, and that table-valued function fn_SplitCommaSep produces one column called TextWithoutComma</p>
  
  <p>eg. something like one of these</p>
  
  <pre><code>select fs.TextWithoutComma
    from fn_SplitCommaSep(select mt.TextWithCommas from MyTable) fs 
  </code></pre>
  
  <p>or </p>
  
  <pre><code>select fs.TextWithoutComma, mt.Id
    from MyTable mt
      inner join fn_SplitCommaSep(mt.TextWithCommas) fs on (something)
  </code></pre>