问个很弱的小问题,马上结贴?........问个很弱的小问题,马上结贴?
set @cmoney= 'select sum(pro_price*pro_amount) from scm_proitem '
update scm_chitty
set chitty_money=@cmoney 这儿怎样写才正确.
where chitty_id=@chitty_id
谢谢大家
------解决方案--------------------update scm_chitty
set chitty_money=t.cmoney
from scm_chitty,(select chitty_id,sum(pro_price*pro_amount) cmoney from scm_proitem group by chitty_id) t
where chitty_id=t.chitty_id
------解决方案--------------------exec( 'update scm_chitty set chitty_money=( '+@cmoney+ ') where chitty_id= '+@chitty_id)
------解决方案-----------------------try
declare @cmoney int
exec sp_executesql N 'select @cmoney=sum(pro_price*pro_amount) from scm_proitem ', '@cmoney int out ', '@cmoney out '
update scm_chitty
set chitty_money=@cmoney --这儿怎样写才正确.
where chitty_id=@chitty_id
------解决方案--------------------declare @chitty_id varchar(10)
update scm_chitty
set chitty_money=(select sum(pro_price*pro_amount) from scm_proitem)
where chitty_id=@chitty_id
------解决方案--------------------select @cmoney= sum(pro_price*pro_amount) from scm_proitem
update scm_chitty
set chitty_money=@cmoney
where chitty_id=@chitty_id