How to loop update total field in procedures in SQL Server?
I have table 1. I want to create procedures to update total field automation.
Table1
Value 1 Value 2 Total
2 4
3 4
3 3
3 1
3 4
PROCEDURE:
Create PROCEDURE test1
AS
Select value1,value2,(value1*value2) as total from Table1
Will update totals for where it’s not set or not in sync (in case values change). Can be extended by adding parameters and such, ofcourse.
Update: Change + to * in case you need to multiply the values instead of add them together.