title: "The column prefix '*' does not match with a table name or alias name used in the query." while using a temp table
body: <p>In a SQL Server 2000 stored procedure, I'm trying to perform an update statement to a table variable.  It is currently giving me the error: "The column prefix 'WST' does not match with a table name or alias name used in the query."</p>
  
  <pre><code>UPDATE WST
  SET
      WST.QtySold = (SELECT SUM(II.QtyShipped)
      FROM #InvoiceItems II
          WHERE II.InvoiceDate &gt;= WST.StartDate
              AND II.InvoiceDate &lt;= WST.EndDate),
      WST.TotalSales = (SELECT SUM(ISNULL(II.QtyShipped, 0) * ISNULL(II.UnitPrice, 0))
          FROM #InvoiceItems II
          WHERE II.InvoiceDate &gt;= WST.StartDate
              AND II.InvoiceDate &lt;= WST.EndDate),
      WST.TotalCost = (SELECT SUM(ISNULL(II.QtyShipped, 0) * ISNULL(II.UnitCost, 0))
          FROM #InvoiceItems II
          WHERE II.InvoiceDate &gt;= WST.StartDate
              AND II.InvoiceDate &lt;= WST.EndDate)
  FROM @WeeklySalesTrend WST
  WHERE WST.WeekNo = 1
  </code></pre>
  
  <p>This error only appeared after I created the temp table #InvoiceItems and replaced the Inner Join of two tables with the temp table.  Why would changing the two-table inner join out for a temp table cause this error and how do I fix/get around it?</p>