2014-10-08 52 views
2

我試圖執行以下更新語句功能:使用表值的更新語句

Update belege2 
Set Preis_Einh = x.Preis, Aktion=x.Aktion, PreisHerk = x.PreisHerk 
FROM dbo.GetPreis(belege2.prodkey, belege2.Anzahl) x 
where belege2.Beleg_Nr = 13599 

SQL Server顯示以下錯誤:

Msg 4104, Level 16, State 1, Line 3 
The multi-part identifier "belege2.prodkey" could not be bound. 

Msg 4104, Level 16, State 1, Line 3 
The multi-part identifier "belege2.Anzahl" could not be bound. 

這難道不是支持?有沒有解決方法?

回答

8

沒有ü嘗試這個別名爲..

Update b 
Set b.Preis_Einh = x.Preis, b.Aktion=x.Aktion, b.PreisHerk = x.PreisHerk 
FROM belege2 b cross apply dbo.GetPreis(b.prodkey, b.Anzahl) x 
where b.Beleg_Nr = 13599 

使用交叉適用