title: Execute stored procedure and update a table
body: <p>I have requirement where I need to update a table using the results from stores procedure.</p>
  
  <p>Example:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Is there a way to do execute the stored procedure for each row in <code>#OrderDetails</code> and update the <code>@orderPrice</code> from the result of a stored procedure?</p>