Updating a record using cursor dating a woman whos ex cheated

DECLARE @saldo_Q_previous FLOAT DECLARE @ID INTEGER DECLARE cursor3 CURSOR FOR SELECT ID FROM @my Table FOR UPDATE OF col2 OPEN cursor3 FETCH NEXT FROM cursor3 INTO @ID FETCH NEXT FROM cursor3 INTO @ID WHILE (@@FETCH_STATUS WITH my Table2 AS ( SELECT col2, col3, ROW_NUMBER() OVER (ORDER BY col2) AS sequence FROM my Table ), new Table AS ( SELECT t1.col2, SUM(t2.col2) - SUM(t2.col3) AS col3 FROM my Table2 t1 LEFT OUTER JOIN my Table2 t2 ON t1.sequence FWIW The major, compelling reason to use a CURSOR is when not doing so, will put too much of a hit on your rdbms.

The cursor is getting values from a column in a different table, using joins to get the correct values.

The result of the select query used returns multiple rows with different values.

So in general it comes down to speed & overhead vs. CURSORS are pretty much the slowest way to go, but have the least amount of overhead and are still useful even in MSSQL 2012 ...

DECLARE @Script varchar(max) DECLARE @get Script CURSOR SET @get Script = CURSOR FOR SELECT [Script] FROM Script Table OPEN @get Script FETCH NEXT FROM @get Script INTO @Script WHILE @@FETCH_STATUS = 0 BEGIN BEGIN TRY EXEC(@Script) --Working part.