我在下面的查询中得到多部分无法绑定错误

update nfltx
set
b.boxno = a.boxno,
b.message = a.message,
b.nameboxno = a.nameboxno,
b.namemsg = a.namemsg,
b.phoneboxno = a.phoneboxno,
b.phonemsg = a.phonemsg

FROM ofltx a JOIN nfltx b
ON a.ls_fullnam = b.ls_fullnam


但是如果我从boxno消息中删除b并且所有我都没有收到错误。这背后的原因是什么?谢谢你使用SQL Server 2008

最佳答案

FROM子句中指定的表别名不能用作SET column_name中的限定符。这是无效的:

update nfltx
set
b.boxno = a.boxno,
b.message = a.message,
b.nameboxno = a.nameboxno,
b.namemsg = a.namemsg,
b.phoneboxno = a.phoneboxno,
b.phonemsg = a.phonemsg

FROM ofltx a JOIN nfltx b
ON a.ls_fullnam = b.ls_fullnam


要使其正常工作,请卸下b。列名的别名。

update nfltx
set
boxno = a.boxno,
message = a.message,
nameboxno = a.nameboxno,
namemsg = a.namemsg,
phoneboxno = a.phoneboxno,
phonemsg = a.phonemsg

FROM ofltx a JOIN nfltx b
ON a.ls_fullnam = b.ls_fullnam


拉吉

关于sql - 多部分标识符无法绑定(bind)sql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14621981/

10-10 04:48