var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Update of previous row in stored procedure
I want to update rows in a table, using a stored procedure, with data from the next fetched row.
The StartDate of the next row has to become the EndDate of the current row.
Below is what I have been trying this far. This is just to figure how to get it to work. It doesn't include ordering the data correctly in order to get the right rows.
Any help would be very much appreciated.
CREATE PROCEDURE USP_StartDate
DECLARE @StartDate datetime
DECLARE @New datetime
DECLARE cur_getstartdate SCROLL CURSOR FOR
SELECT StartDt FROM Table1
ORDER BY StartDt
FETCH LAST FROM cur_getstartdate
WHILE @@FETCH_STATUS = 0
SET @New = @StartDate
FETCH PRIOR FROM cur_getstartdate
UPDATE BaremeExtensionReferenceSalary SET EndDt=@New