if you add the additional sequencing column to your table as swampboogie suggested, yes it does work
relational databases do not maintain a sequence of rows in a table
any sequence you want must be explicitly specified in the ORDER BY clause, or implicit in the use of comparison operators like < (less than), which is what swampboogie's query uses
DECLARE @row_name numeric,
@RunningTotal numeric
SET @RunningTotal = 0
DECLARE Cumulative_Cur CURSOR
FOR
SELECT row_name
FROM table_name
OPEN Cumulative_Cur
FETCH NEXT FROM Cumulative_Cur INTO @row_name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @RunningTotal = @RunningTotal + @row_name
INSERT #Temp_Cumulative_Table VALUES (@row_name,@RunningTotal)
FETCH NEXT FROM Cumulative_Cur INTO @row_name
END
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.