从表值函数更新虚拟表,需要从虚拟表传参数进去,一直报这个错,求教该如何写才对
从表值函数更新虚拟表,需要从虚拟表传参数进去,一直报这个错,求教该怎么写才对?
无法绑定由多个部分组成的标识符 "#table.yto_account"。
问:从表值函数更新虚拟表,需要从虚拟表传参数进去,一直报这个错,求教该怎么写才对?
------解决方案--------------------
这个语句不可以这么写
update #table
set #table.qichu=fn.qichu,#table.yingshou=fn.yingshou,#table.threeMonth=fn.threeMonth
from dbo.Frensworkz_getCYJzhujichangXY_Report(#table.yto_account,@endDateUTC) as fn
你改为
update #table
set #table.qichu=fn.qichu,#table.yingshou=fn.yingshou,#table.threeMonth=fn.threeMonth
from (select * from #table.yto_account where xxx=@endDateUTC) as fn
------解决方案--------------------
改成这样试试
------解决方案--------------------
select acc.yto_sapcode,yas.yto_accountName,yas.yto_account,
0 as qichu,0 as yingshou,0 as threeMonth,0 as sixMonth,0 as twelveMonth,0 as twoYear,0 as threeYear,0 as beforeThreeYear
into #table
from yto_accountsreceivable yas
left join Account acc on yas.yto_account=acc.AccountId
where yas.statecode=0 and acc.StateCode=0 and acc.yto_accounttype=1
group by yas.yto_accountName,yas.yto_account,acc.yto_sapcode
update #table set #table.qichu=fn.qichu,#table.yingshou=fn.yingshou,#table.threeMonth=fn.threeMonth
from dbo.Frensworkz_getCYJzhujichangXY_Report(#table.yto_account,@endDateUTC) as fn
无法绑定由多个部分组成的标识符 "#table.yto_account"。
问:从表值函数更新虚拟表,需要从虚拟表传参数进去,一直报这个错,求教该怎么写才对?
表值函数
虚拟表
SqlServer
SQL
------解决方案--------------------
这个语句不可以这么写
update #table
set #table.qichu=fn.qichu,#table.yingshou=fn.yingshou,#table.threeMonth=fn.threeMonth
from dbo.Frensworkz_getCYJzhujichangXY_Report(#table.yto_account,@endDateUTC) as fn
你改为
update #table
set #table.qichu=fn.qichu,#table.yingshou=fn.yingshou,#table.threeMonth=fn.threeMonth
from (select * from #table.yto_account where xxx=@endDateUTC) as fn
------解决方案--------------------
update #table
set #table.qichu=fn.qichu,#table.yingshou=fn.yingshou,#table.threeMonth=fn.threeMonth
from #table cross apply
dbo.Frensworkz_getCYJzhujichangXY_Report(#table.yto_account,@endDateUTC) as fn
改成这样试试
------解决方案--------------------