Using table-valued function in update statement

♀尐吖头ヾ 提交于 2019-12-24 01:47:37

问题


I'm trying to execute the following update statement:

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 displays the following errors:

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.

Is this not supported? Is there a workaround?


回答1:


did u try this with alias..

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

used cross apply



来源:https://stackoverflow.com/questions/26253866/using-table-valued-function-in-update-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!