title: How to declare and initialize user defined table type?
body: <p>I created this user table type</p>
  
  <pre><code>CREATE TYPE [dbo].[IntArray] AS TABLE
  (
      IntValue INT
  )
  </code></pre>
  
  <p>I also created a function</p>
  
  <pre><code>CREATE FUNCTION [dbo].[fnProcessIntArray]
  (
      @IntArray as dbo.intArray READONLY
  )
  RETURNS NVARCHAR(max)
  AS
  BEGIN
  -- Input is table of int values
  -- Output example : '1,2,3,4'
  ...
  END
  </code></pre>
  
  <p>now I need to test a function but I don't know how, I tried</p>
  
  <pre><code>SELECT dbo.fnProcessIntArray((SELECT 1))
  -- Error: Operand type clash: int is incompatible with IntArray
  
  SELECT dbo.fnProcessIntArray((SELECT 1,2,3,4))
  -- Error: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
  </code></pre>
  
  <p>How can I DECLARE @intArray as dbo.IntArray ?</p>