我创建了一个这样的临时表:
SELECT
email_key,
Best_pn_ee_active_pbm,
Best_pn_ee_active_pbm_pub,
Best_pn_ee_active_pbm_status,
Best_pn_ee_inactive_pbm,
Best_pn_ee_inactive_pbm_pub,
Best_pn_ee_inactive_pbm_status
INTO #kjs_univ_sample
FROM view_univ_email
我随后添加了一些要在以后填充的列:
ALTER TABLE #kjs_univ_sample
ADD Best_pn_ee_active_pbm_my varchar(10),
Best_pn_ee_active_pbm_status_my varchar(10),
Best_pn_ee_active_pbm_pub_my varchar(10),
Best_pn_ee_inactive_pbm_my varchar(10),
Best_pn_ee_inactive_pbm_status_my varchar(10),
Best_pn_ee_inactive_pbm_pub_my varchar(10)
然后我尝试更新我刚刚添加的字段:
UPDATE #kjs_univ_sample
SET
a.Best_pn_ee_active_pbm_my = b.s_pbm_account_key,
a.best_pn_ee_active_pbm_pub_my = b.s_pub_code,
a.best_pn_ee_active_pbm_status_my = b.s_subscription_status
FROM #kjs_univ_sample as a
RIGHT JOIN #kjsemailcount as b ON a.email_key = b.email
WHERE a.email_key = b.email
AND b.counted = '1'
问题是通过ALTER
添加的所有4列都显示错误
'无法绑定多部分标识符“”。
我尝试在Update
行中使用别名'a',而根本不使用别名。当我输入要更新的字段的名称时,它会显示下拉列表,但ALTER
添加的字段都没有。
就像它没有看到它们一样。然而,Select *
会显示它们。有任何想法吗?
答案 0 :(得分:0)
此代码有效:
update #kjs_univ_sample
set Best_pn_ee_active_pbm_my = b.s_pbm_account_key,
best_pn_ee_active_pbm_pub_my = b.s_pub_code,
best_pn_ee_active_pbm_status_my = b.s_subscription_status
from #kjs_univ_sample as a
right join #kjsemailcount as b
on a.email_key = b.email
where a.email_key = b.email
and b.counted = '1'
我删除了a。正如之前由@ Gordon-Linoff所建议的那样。它没有删除警告消息,但最终确实有效。