title: Assign Data to a User-Defined Table type from Select Query?
body: <p>I have a stored procedure which retrieves three columns from multiple tables. I want to get the results in a user defined multi-valued table and pass the variable to another procedure to perform operations on the variable data.</p>
  <p>However it is not working. Any idea why it this not working?</p>
  <pre><code>--This is the initial stored procedure
  Create Procedure spSelectData
  AS
  BEGIN
      Select 
          Userid, first_date, last_update
      From Users
  END
  
  --This is to create the table type.
  Create type Task1TableType AS TABLE
  (
       Userid nvarchar(20),
       First_date datetime,
       Last_update datetime
  )
  
  --Declare a table of type 
  DECLARE @firstStep AS Task1TableType
  (
      Userid nvarchar(20),
      First_date datetime,
      Last_update datetime
  )
  
  Insert @firstStep EXEC spSelectData
  
  Select * from @firstStep
  
  -- This is the procedure 1
  CREATE PROC spTest1
     @TTType Task1TableType READONLY
  AS
  BEGIN
      Select * from @TTType
  END
  </code></pre>