在update语句中使用表值函数

doe*_*rig 2 sql t-sql sql-server sql-server-2008-r2

我正在尝试执行以下更新语句:

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
Run Code Online (Sandbox Code Playgroud)

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.
Run Code Online (Sandbox Code Playgroud)

这不受支持吗?有解决方法吗?

Rec*_*ive 9

你用别名试试这个吗?

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
Run Code Online (Sandbox Code Playgroud)

使用交叉申请