Ver Mensaje Individual
  #3  
Antiguo 28-06-2008
pcicom pcicom is offline
Miembro
 
Registrado: may 2003
Ubicación: MONTERREY MEXICO
Posts: 253
Reputación: 24
pcicom Va por buen camino
Espero te sirva este ejemplo....

Creando Cursors no olvides nunca cerrarlo al finall..


Código SQL [-]


DECLARE @dcliente int
DECLARE @dnombre string


DECLARE MyCursor CURSOR FOR
   SELECT cliente,nombre FROM clientes

OPEN MyCursor
FETCH NEXT FROM MyCursor INTO @dcliente,@dnombre
WHILE @@FETCH_STATUS = 0
BEGIN

    PRINT @dcliente,@dnombre

    --   INSTRUCCIONES A realizar
    --   

    // Lee el Siguiente Registro 
    FETCH NEXT FROM myCursor INTO @dcliente,@dnombre

END;

CLOSE myCursor
__________________
Poco ha de saber el que no pregunta.. Yo por eso soy un pregunton

Última edición por pcicom fecha: 28-06-2008 a las 17:04:42.
Responder Con Cita