title: Invalid object name 'User-Defined-Table-Type'
body: <p>I am getting error:</p>
  
  <pre><code>Invalid object name 'UDTT_SuppliersList'.
  </code></pre>
  
  <p>Which is User-Defined table type as:</p>
  
  <pre><code>CREATE TYPE [dbo].[UDTT_SuppliersList] AS TABLE(
      [SupplierID] [int] NOT NULL,
      [Region_Name] [varchar](255) NULL,
      PRIMARY KEY CLUSTERED 
  (
      [SupplierID] ASC
  )WITH (IGNORE_DUP_KEY = OFF)
  )
  GO
  </code></pre>
  
  <p>I am using it (pass as parameter) with StoredProcedures and it is working fine. But today I tried to pass it as parameter to Table-Valued function. Table is created successfully with no errors. But when I try to call that function it is giving me error as mentioned above. </p>
  
  <pre><code>declare @tbl_UDTT_SuppliersList UDTT_SuppliersList 
  --declare, and assume populated with data
  
  select* from dbo.GetSupplierInvoicesByDate(@tbl_UDTT_SuppliersList)
  </code></pre>
  
  <p>Here is the function code:</p>
  
  <pre><code>ALTER FUNCTION [dbo].[GetSupplierInvoicesByDate]
  (
      @tbl_UDTT_SuppliersList as dbo.UDTT_SuppliersList READONLY
  )
  RETURNS 
  @tableList TABLE(
      SupplierID int,
      InvoiceAmount decimal(19, 3)
      )
  AS
  BEGIN
      INSERT INTO @tableList (
          SupplierID, 
          InvoiceAmount
      )
  
      SELECT 
      inv.SupplierID as SupplierID
      ,inv.Amount as InvoiceAmount
      FROM dbo.Invoices inv
      inner join UDTT_SuppliersList tSupp on tSupp.SupplierID = inv.SupplierID
      WHERE inv.IsPaidFully = 0
  
      RETURN
  END
  </code></pre>