我需要使用存储过程的结果更新表格。
示例:
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
?
答案 0 :(得分:0)