我有以下查询:
--UPDATE
UPDATE p.fact_usersortcustomer
set
cellid = usc.cellid,
dwupdatedate = getdate()
from s.userSortCustomer usc
JOIN t.append_fact_usersortcustomer ON usc.actiondate = t.actiondate AND usc.ucdmid = t.ucdmid AND usc.sortid = t.sortid
但更新不起作用,因为我收到以下错误:
[错误]脚本行:10-17 ------------------------ 错误:目标表必须涉及非笛卡尔内连接
有什么想法吗?
答案 0 :(得分:1)
我想你想用
UPDATE p.fact_usersortcustomer usc
set
cellid = usc.cellid,
dwupdatedate = getdate()
FROM (select ucdmid, sortid, actiondate from append_fact_usersortcustomer) a
WHERE usc.ucdmid = a.ucdmid
AND usc.sortid = a.sortid
AND usc.actiondate = a.actiondate;
答案 1 :(得分:1)
update
中未提及from
后的表格。这导致"笛卡尔产品"。据推测,你想要这样的东西:
UPDATE p
set cellid= usc.cellid,
dwupdatedate = getdate()
from s.userSortCustomer usc join
t.append_fact_usersortcustomer t
ON usc.actiondate = t.actiondate AND usc.ucdmid = t.ucdmid AND usc.sortid = t.sortid join
p.fact_usersortcustomer p
ON . . . ;
但是,我不知道join
条件是什么。他们去了. . .
。