早上好。
我正在使用先前查询的结果填充多对多表,如下所示...
WITH Temp AS
(
SELECT UserID, Result
FROM <Master_Table>
WHERE UserID IN (SELECT Name FROM Users)
)
INSERT INTO UserDecisions
(User_Id, Decision_Id)
VALUES
(
(SELECT Id FROM Users WHERE Temp.UserID = Users.Name),
(SELECT Id FROM Decisions WHERE Temp.Result = Decisions.Name)
)
在执行时,我收到如下错误。
Msg 4104, Level 16, State 1, Line 22
The multi-part identifier "Temp.UserID" could not be bound.
Msg 4104, Level 16, State 1, Line 23
The multi-part identifier "Temp.Result" could not be bound.
请问你会如何解决这个问题?Temp 子查询是否需要是临时表?