我試圖更新表中的一組記錄與另一組記錄在同一個表中的值。當我運行此查詢,我得到錯誤:使用子查詢進行更新會出錯:「多部分標識符無法綁定。」 (Sql Server 2008)
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "t.com" could not be bound.
代碼:
update tphase
set
t.com = t.com + b.com,
t.direct = t.direct + b.direct,
t.fee = t.fee + b.fee,
t.fringe = t.fringe + b.fringe,
t.fte = t.fte + b.fte,
t.ganda = t.ganda + b.ganda,
t.hours = t.hours + b.hours,
t.overhead = t.overhead + b.overhead,
t.fccmga = t.fccmga + b.fccmga,
t.fccmoh = t.fccmoh + b.fccmoh,
t.lbroh = t.lbroh + b.lbroh,
t.ms = t.ms + b.ms
from
tphase t
inner join
(select *
from tphase
where program = 'xenon' and
class = 'earned' and
df_date > '2013-05-03'
) as b on t.program = b.program and
t.cawpid = b.cawpid and
t.class = b.class and
t.cecode = b.cecode
where
t.program = 'xenon' and
t.class = 'earned' and
t.df_date = '2013-05-03' ;
你可以張貼'tphase'的表結構? – 2013-05-13 18:21:14
'CREATE TABLE TPHASE \t( \t PROGRAM爲nvarchar(22), \t CAWPID INT, \t CECODE爲nvarchar(59), \t CLASS爲nvarchar(20), \t DF_DATE日期時間, \t BATCHNO INT, \t COM十進制(21,6), \t DIRECT十進制(21,6), \t FEE十進制(21,6), \t FRINGE十進制(21,6), \t FTE十進制(21,6), \t甘達公十進制(21,6), \t HOURS十進制(21,6), \t OVERHEAD十進制(21,6), \t FCCMGA十進制(21,6), \t FCCMOH十進制(21,6), \t LBROH十進制(21,6), \t MS十進制(21,6) \t)' – user2378895 2013-05-14 02:12:51