我有需要使用存储过程的结果更新表的要求。
例子:
Declare @result1 decimal
Declare @price deciaml
Create Table #OrderDetails
{
@orderID bigint
,@orderName nvarchar(9)
,@orderPrice decimal
,@orderFlag nchar(1)
}
Insert into #OrderDetails
{
@orderID
,@orderName
,@orderPrice
,@orderFlag
} Select * from CartDetails
Update #OrderDetails
set @orderFlag = 1
from #OrderDetails
where orderID = 1
--Now update each row of #OrderDetails by calling a stored procedure
Update #OrderDetails
set @orderPrice= @result1
from (exec store_proc_calc_price orderID, orderName, @price = @result1 Output)
有没有办法为每一行执行存储过程#OrderDetails
并更新@orderPrice
存储过程的结果?