Jul
9
Written by:
Steve Gray
7/9/2009 3:14 PM
This is the cursor template that I use... it works better than the default one, and allows BREAK and CONTINUE easily
DECLARE variables
DECLARE curName CURSOR LOCAL FAST_FORWARD FOR
select *
from mytablename
OPEN curName
WHILE 1=1
BEGIN
FETCH NEXT FROM curName INTO
if @@fetch_status <> 0 begin
break
end
END
CLOSE curName
DEALLOCATE curName
As always, I welcome your comments!