65.9K
Home

Always close your cursor

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Oct 13, 2011

CPOL
viewsIcon

5095

An alternative (simpler way :) ) is:BEGIN TRANDECLARE IdCursor CURSOR FOR SELECT Id FROM MyTable OPEN IdCursor FETCH NEXT FROM IdCursor INTO @CurrentIdWHILE (@@FETCH_STATUS) = 0 BEGIN -- do work IF @@error 0...