martes, 26 de febrero de 2008

T-SQL Cursors (autoreminder)


DECLARE thecursor CURSOR FOR SELECT ...;
OPEN thecursor;
FETCH NEXT FROM thecursor INTO @thevariable;
WHILE @@FETCH_STATUS = 0
BEGIN
...
FETCH NEXT FROM thecursor INTO @thevariable;
END
CLOSE thecursor;
DEALLOCATE thecursor;

No hay comentarios: