0

我正在尝试在 sql server 2008r2 上执行此查询-

SELECT @lUpd1 = 'UPDATE ts1cust.dbo.t_grgr_xwalk 
SET    xwalk.WEB = info.WEB,xwalk.AVIVIA = info.AVIVIA,xwalk.MSP = info.MSP,xwalk.QO   =    info.QO
FROM   ts1cust.dbo.t_plan_mspqo_info info, ts1cust.dbo.t_grgr_xwalk xwalk
WHERE  info.PLANID = xwalk.ID_471'

但得到以下提到的错误-

 Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "xwalk.WEB" could not be bound.
4

3 回答 3

0

您将表别名t_grgr_xwalkxwalk,因此对于第一个表达式,Update Table您也应该使用xwalk

SELECT @lUpd1 = 'UPDATE xwalk
SET    WEB = info.WEB,
       AVIVIA = info.AVIVIA,
       MSP = info.MSP,
       QO = info.QO
FROM   ts1cust.dbo.t_plan_mspqo_info info, ts1cust.dbo.t_grgr_xwalk xwalk
WHERE  info.PLANID = xwalk.ID_471'
于 2013-03-13T09:06:18.020 回答
0

您可以在下面尝试: SELECT @lUpd1 = 'UPDATE ts1cust.dbo.t_grgr_xwalk xwalk SET xwalk.WEB = info.WEB,xwalk.AVIVIA = info.AVIVIA,xwalk.MSP = info.MSP,xwalk.QO = info.QO FROM ts1cust.dbo.t_plan_mspqo_info info WHERE info.PLANID = xwalk.ID_471'

于 2013-03-13T09:07:02.963 回答
0

您不能在SET子句中的列的赋值侧使用多部分标识符。

SELECT @lUpd1 = 'UPDATE xwalk
SET    WEB = info.WEB, --<-- no xwalk. here
       AVIVIA = info.AVIVIA,
       MSP = info.MSP,
       QO   =    info.QO
FROM   ts1cust.dbo.t_plan_mspqo_info info
   INNER JOIN
       ts1cust.dbo.t_grgr_xwalk xwalk
         ON  info.PLANID = xwalk.ID_471'

我还冒昧地将表引用替换为您在顶部使用的别名UPDATE,并切换到使用 ANSIJOIN而不是,

于 2013-03-13T09:08:08.393 回答