Iterate through the table and calculate the total price through storeprocedure

create proc test
as
Select price_id Into  #Temp From   agreement_price
Declare @Id int
declare @val int
Declare @calc int
declare @it int

set @val=0
set @it=(Select Count(*) From #Temp)
While (@it) > 0
Begin
  set @calc=(select price from price where price_id in (Select Top 1 price_id From  #Temp))
  set @val=@val+@calc
set @id=(Select Top 1 price_id From  #Temp)
 Delete from #Temp Where price_id= @Id
set @it=@it-1
End
select @val
exec test