Check my table below:
ID Number01 Number02 Number03
-----------------------------------
1 10 20 4510
2 5 2 545
3 4 4 664
4 10 1 NULL
5 1 4 NULL
"Number03" field is a calculated field which is Number01 + Number02. I am using a stored procedure to calculate it. Why I am using a stored procedure? Because I have the interface which made by asp.net.
This is the stored procedure:
ALTER PROCEDURE _mySP
(@Number01 decimal(18,0), @Number02 decimal(18,0))
AS
BEGIN
DECLARE @myCOM1 float
DECLARE @myCOM2 float
SET @myCOM1 = @Number1 + 500
SET @myCOM2 = POWER(@Number2, 2) * 10
INSERT INTO _myTable(Number01, Number02, Number03)
VALUES (@Number01, @Number02, @myCOM1 + @myCOM2)
END
The question is, how can I execute the stored procedure without entering the value one by one? Because the value is already in the table. I want to update all the null value on "Number03" field. Also any idea how execute my question using CURSOR?
EDIT: It seems that my previous question is too simple. So I make it complex a little bit.
Update _mySP Set Number03 = Number01 + number02