title: How to return temporary table from stored procedure
body: <pre><code>CREATE PROCEDURE [test].[proc]
  @ConfiguredContentId int,
  @NumberOfGames int
  AS
  BEGIN
   SET NOCOUNT ON
   RETURN 
   @WunNumbers TABLE (WinNumb int)
  
      INSERT INTO @WunNumbers (WinNumb)
   SELECT TOP (@NumberOfGames) WinningNumber
   FROM [Game].[Game] g
   JOIN [Game].[RouletteResult] AS rr ON g.[Id] = rr.[gameId]
   WHERE g.[ConfiguredContentId] = @ConfiguredContentId
   ORDER BY g.[Stoptime] DESC
  
   SELECT WinNumb, COUNT (WinNumb) AS "Count"
   FROM @WunNumbers wn
   GROUP BY wn.[WinNumb]
  END
  GO
  </code></pre>
  
  <p>This stored procedure returns values from first select statement, but I would like to have values from second select statement to be returned. Table @WunNumbers is a temporary table.</p>
  
  <p>Any ideas???</p>