title: SQL Function INPUT Table Type in query
body: <p>For MS SQL 2016</p>
  
  <p>I have user table 'table TYPE t_Table(Id int, String nvarchar (max))'</p>
  
  <p>Also I have function 'f_get(@T t_Table)' </p>
  
  <p>There is some code... equivalent' STRING_AGG' --<em>I Can not use this function because of the version of SQL</em></p>
  
  <p>The function works correct when I use type t_Table...</p>
  
  <pre><code> DECLARE @T t_Table
   INSERT INTO @T
   SELECT 1, 'John' UNION
   SELECT 2, 'Mark'
  
   SELECT f_get(@T)...
  </code></pre>
  
  <p>But I would like to use this function in QUERY</p>
  
  <pre><code> SELECT f_get(
   SELECT 1, 'John' UNION
   SELECT 2, 'Mark'
  )
  </code></pre>
  
  <p>.... but it doesnot work</p>
  
  <p>Or in query</p>
  
  <pre><code> SELECT * FROM orders o
   OUTER APLLY f_get(
   SELECT ID, Name as String FROM table t WHERE t.OrderId = o.OrderId 
    )
  </code></pre>
  
  <p>Is there any way how can I do this?
  Thank you
  David</p>