It would be easy if you have an additional sequence column (e.g. UniqeID). If you have, you can just have it this way
Update CumulativeTable
SET Cumulative = Value + (Select Sum(Value) From CumulativeTable Where UniqueID < c.UniqueID
AND ID = c.ID)
From CumulativeTable c
or if you don't have, you can try this,
DECLARE @TempTable TABLE (UniqueID int IDENTITY,
ID int,
Value numeric(18,3),
Cumulative numeric(18,3)
)
DECLARE @TempTable TABLE (UniqueID int IDENTITY,
ID int,
Value numeric(18,3),
Cumulative numeric(18,3)
)
Insert Into @TempTable (ID, Value, Cumulative)
Select ID, Value, Cumulative From CumulativeTable
Update CumulativeTable
SET Cumulative = COALESCE(c.Value + (Select Sum(Value) From @TempTable Where UniqueID < c.UniqueID
AND ID = c.ID),0)
From CumulativeTable t, @TempTable c
Where t.ID = c.ID AND t.Value = c.Value
but this will not give you correct value if you have multiple records with the same ID and value