1
저장 프로 시저의 결과를 사용하여 테이블을 업데이트해야하는 요구 사항이 있습니다.저장 프로 시저 실행 및 테이블 업데이트
예 :
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
를 업데이트 할 수있는 방법이 있나요?
현재 구현에는 커서가 있으며 커서를 제거하려고 시도하고 있습니다. – user1825332
커서에 어떤 문제가 있습니까? 테이블의 모든 라인에 대해 sp를 호출하는 다른 방법은 없습니다 ... –