I have a temp table @table in my stored procedure that looks like this:
AgtID | Bonus
-------------
5063 | 0
1104 | 0
And a table bonus that looks like this:
AgtID | Contest | Points | Event
--------------------------------
5063 | 21 | 1000 | 1
5063 | 21 | 3000 | 3
1104 | 21 | 1000 | 1
1104 | 21 | 500 | 2
And an update query (currently) like thus:
UPDATE tt
SET Bonus = b.Points
FROM @table tt
INNER JOIN tblContestData_Bonus b
ON tt.AgtID = b.AgtID
where ContestID = 21;
Currently, when I run this query, it'll overwrite whatever data is in @table.Bonus with the data in bonus.Points. This is fine for a single record, but as we start getting more bonus point events, I need to have it add to my value.
I know some languages have a i += value... does SQL have something similar?
AgtIDyou have more than oneeventso which eventpointsyou have to update to@table