title: Insert into temp table from stored procedure causes error
body: <p>I have this stored procedure:</p>
  
  <pre><code>ALTER Procedure [dbo].[sp_Prd_Dashboard_Summary]
      (@Period AS INT)
  AS
      SELECT 
          SiteName AS SiteName, 
          MAX(Country) AS Country, 
          BudgetPrj, 
          MAX(PeriodEnd) AS PeriodEnd, 
          MAX(DaysMtd) AS DaysMtd,
          MAX(ToGoMtd) AS ToGoMtd, 
          MAX(PeriodToTDays) AS PeriodToTDays,
          SUM(MTDRevenue) AS MtdRev, 
          SUM(MTDRevenue) / NULLIF(MAX(DaysMTD), 0) * MAX(PeriodToTDays) AS PrjRevenue,
          SUM(BdgRevenue) AS BdgRev, SUM(TrgRevenue) AS TrgRev,
          SUM(BCMMtd) AS BCMMtd, SUM(HrsMtd) AS HrsMTD, 
          SUM(FuelVal) AS FuelVal, SUM(FuelLtrs) AS FuelLtrs,
          SUM(FuelVal) / NULLIF(SUM(MTDRevenue), 0) AS FuelPerc
      FROM
          (SELECT
               St.SiteName as SiteName,
               St.Country as Country, 
               Null as BudgetPrj, Prd.PeriodEnd as PeriodEnd,
               Day(GetDate()) as DaysMtd, 
               Prd.PeriodNoDays - Day(GetDate()) as ToGoMtd,
               Prd.PeriodNoDays as PeriodToTDays,
               0 as MTDRevenue, 0 as BdgRevenue, 
               0 as TrgRevenue, 0 as BCMMtd,
               0 as HrsMtd, 0 as FuelVal,
               0 as FuelLtrs
           FROM 
               Periods Prd 
           JOIN
               Sites St ON Prd.PeriodSiteID = St.SiteId
           WHERE
               Prd.Period = @Period AND St.SiteActive = 1
  
           UNION All
  
      Select SiteName as SiteName
      , Dit.Country as Country
      , Null as BudgetPrj
      , Null as PeriodEnd
      , 0 DaysMtd
      , 0 as ToGoMtd
      , 0 as PeriodToTDays
      , IIF(Dit.Wcode = 101, 
              IIF(DiT.WBillMeth = 'Hours', DiT.Hrs * DiT.OpBill,
                  IIF(DiT.WBillMeth = 'BCM', Loads * DiT.ModelSize * DiT.WBillRate,
                      IIF(DiT.WBillMeth = 'Cost Plus', (DiT.Hrs * (DiT.OwnBill + DiT.OpBill)) +
                          (DiT.ShiftHrs * DiT.EmpBill),0))),0) as MTDRevenue
      , 0 as BdgRevenue
      , 0 as TrgRevenue
      , IIF(DiT.WBillMeth = 'BCM', Loads * DiT.ModelSize, 0) as BCMMtd
      , IIF(Dit.Wcode = 101, 
              IIF(DiT.WBillMeth &lt;&gt; 'BCM', DiT.Hrs, 0),0) as HrsMtd
      , DiT.Fuel * DiT.FuelRate as FuelVal
      , DiT.Fuel as FuelLtrs
  
      From DataInputTotal DiT
  
      Where DiT.Period = @Period and DiT.SiteActive = 1
  
      Union All
  
      Select SiteName as SiteName
      , St.Country as Country
      , Bdgt.BudgetProject as BudgetPrj
      , Prd.PeriodEnd as PeriodEnd
      , 0 as DaysMtd
      , 0 as ToGoMtd
      , 0 as PeriodToTDays
      , 0 as MTDRevenue
      , PrjRev as BdgRevenue
      , BudgTarget as TrgRevenue
      , 0 as BCMMtd
      , 0 as HrsMtd
      , 0 as FuelVal
      , 0 as FuelLtrs
  
      From Budget Bdgt Join 
          Sites St on Bdgt.SiteId = St.SiteId Join
          Periods Prd on Bdgt.Period = prd.Period and Bdgt.SiteId = Prd.PeriodSiteID
  
      Where Bdgt.Period = @Period and St.SiteActive = 1
  
  ) a
  
  
  Group By SiteName, BudgetPrj
  </code></pre>
  
  <p>I am trying to call the procedure and insert the result into a temp table with the below script:</p>
  
  <pre><code>Declare @Period int = 22
  Declare @DaysinMonth Int = 29
  Declare @DayHrs Int = 24
  
  IF OBJECT_ID('tempdb..#Temp') IS NOT NULL DROP TABLE #Temp
  
  Create Table #Temp (SiteName nvarchar(50)
                      , Country nvarchar(50)
                      , BudgetPrj nvarchar(50)
                      , PeriodEnd DateTime
                      , DaysMtd Int
                      , ToGoMtd Int
                      , PeriodToTDays Int
                      , MtdRev Numeric(13,2)
                      , PrjRevenue Numeric(13,2)
                      , BdgRev Numeric(13,2)
                      , TrgRev Numeric(13,2)
                      , BCMMtd Numeric(13,2)
                      , HrsMtd Numeric(13,2)
                      , FuelVal Numeric(13,2)
                      , FuelLtrs Numeric(13,2)
                      , FuelPerc Numeric(13,2)
                      , FltCnt Int
                      , Availibility Numeric(13,2)
                      , Utilization Numeric(13,2)
                      , Idle Numeric(13,2)
                      )
  
  Insert #temp
  Exec sp_Prd_Dashboard_Summary @Period
  Insert into #temp
  Exec summary_fleet_performance @DayHrs, @Period, @DaysinMonth
  </code></pre>
  
  <p>When running the script I get the following error:</p>
  
  <blockquote>
    <p>Column name or number of supplied values does not match table definition.</p>
  </blockquote>
  
  <p>I have checked the aliases of the <code>SELECT</code> and all columns have names.</p>