Sie sind auf Seite 1von 1

/declaramos el Cursor para la consulta

DECLARE TODOS CURSOR FOR

SELECT PK_CVEPROFESOR FROM DBO.T012_CPROFESOR ORDER BY


PK_CVEPROFESOR

/*Abrimos el cursor*/

OPEN TODOS

/*Extraemos el Primer registo*/


FETCH NEXT FROM TODOS

INTO @PROFESOR

/* imprimimos todos los registros mientras la variable


@@FETCH_STATUS sea igual a 0*/


WHILE @@FETCH_STATUS = 0

BEGIN


PRINT @PROFESOR

/*Nos Movemos al siguiente registro*/


FETCH NEXT FROM TODOS INTO @PROFESOR

END

/*cerramos el cursor*/


CLOSE TODOS


DEALLOCATE TODOS
- See more at: http://www.scriptmatico.com/2007/08/13/recorrer-una-tabla-con-t-sql-
usando-cursores/#sthash.nS4FQwu5.dpuf

Das könnte Ihnen auch gefallen