首先,我创建了一个包含一列的内存表,并使用这些列值与另一个表进行了内部连接。这样做时,我收到此错误:
必须声明标量变量@Temporary。
谁能解释我哪里出错了?
DECLARE @ID INT
Declare @Temporary Table
(
AccountID INT
)
DECLARE cur CURSOR FOR
SELECT DISTINCT ParentItem from ItemBillOfMaterial
OPEN cur
FETCH NEXT FROM cur INTO @ID;
WHILE @@FETCH_STATUS = 0
BEGIN
Insert into @Temporary Values(@ID)
FETCH NEXT FROM cur INTO @ID;
END
SELECT UOM FROM Item
INNER JOIN @Temporary
ON Item.ItemID=@Temporary.AccountID
CLOSE cur;
DEALLOCATE cur;