这是声明。子查询本身返回正确的值,但在update语句中它表示返回多个值。
update MasterList
set SSI_Rep = (select [SS Rep] from RepAssign join
MasterList on MasterList.ST = RepAssign.State
and MasterList.RSM = RepAssign.RSM )
答案 0 :(得分:2)
尝试以下方法:
UPDATE
MasterList
SET
SSI_Rep = RepAssign.[SS Rep]
from
MasterList
join
RepAssign
on
MasterList.ST = RepAssign.State
and MasterList.RSM = RepAssign.RSM
答案 1 :(得分:0)
如上所述,查询尝试使用相同的SSI_Rep值更新Masterlist中的所有行。因此,错误消息正确地说明您正在尝试使用许多值更新行值。我敢打赌,这不是你想要做的,你想要做一个UPDATE FROM查询:
UPDATE MasterList
SET SSI_Rep = RepAssign.[SS Rep]
FROM MasterList
JOIN RepAssign
ON MasterList.ST = RepAssign.State
AND MasterList.RSM = RepAssign.RSM