SyntaxTerror
Technical User
SQL Server 2005 is saying that Wk1Usage.Wk1Usage in the update statement for my temp table can't be bound, but I don't see any problems with my syntax. Help? :S The subquery in the update runs flawlessly.
Code:
CREATE TABLE #temp_usage
(
SiteID CHAR(10),
InvtID CHAR(30),
Wk1Usage FLOAT,
Wk2Usage FLOAT,
Wk3Usage FLOAT,
Wk4Usage FLOAT,
Wk5Usage FLOAT,
Wk6Usage FLOAT,
Total FLOAT
)
INSERT INTO #temp_usage
SELECT SiteID,
InvtID,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
FROM dbo.itemsite
WHERE invtid NOT LIKE '%NS%'
AND invtid NOT LIKE '%MER%'
GROUP BY SiteID, InvtID
UPDATE #temp_usage
SET Wk1Usage.Wk1Usage=usage.Wk1Usage
FROM #temp_usage as usage
LEFT JOIN ( SELECT counts.SiteID as SiteID,
xtran.invtID as invtID,
(xtran.PreviousCount+pos.Wk1POqty-xtran.currentcount) AS Wk1Usage
FROM xinvtcounttran as xtran
LEFT JOIN #temp_counts AS counts ON counts.Week1CountID=xtran.CountID
INNER JOIN #temp_pos AS pos ON pos.InventoryID=xtran.invtID
WHERE counts.SiteID='A01-01' AND pos.SiteID='A01-01') as Wk1Usage
ON usage.SiteID=Wk1Usage.SiteID AND usage.InvtID=Wk1Usage.InvtID
WHERE usage.SiteID=Wk1Usage.SiteID AND usage.InvtID=Wk1Usage.InvtID