--Variables de los campos del Cursor
DECLARE @ID UNIQUEIDENTIFIER
DECLARE @ArticuloCodigo VARCHAR(100)
DECLARE @Contador int
--Declaración del Cursor
DECLARE @cursor CURSOR
--Inicializa el Cursor
SET @cursor = CURSOR FAST_FORWARD FOR (SELECT ROW_NUMBER() OVER(ORDER BY ART_articuloId),ART_articuloId, ART_CodigoArticulo FROM Articulos)
OPEN @cursor
--Primer Elemento
FETCH NEXT FROM @cursor INTO @Contador, @ID, @ArticuloCodigo
--Ciclo While del Cursor
WHILE @@FETCH_STATUS = 0
--INICIO CLICLO
BEGIN
PRINT '------------------------------------------------'
PRINT 'ARTICULO: No. '+CONVERT(VARCHAR(20), @Contador) + ' - '+@ArticuloCodigo
PRINT 'ID: '+CONVERT(VARCHAR(40),@ID)
--SIGUIENTE ELEMENTO
FETCH NEXT FROM @cursor INTO @Contador, @ID, @ArticuloCodigo
--FIN CLICLO
END
CLOSE @cursor
DEALLOCATE @cursor
PRINT ''
PRINT '++++++++++++++++++++++++++++++++++++++++++++++++'
print 'No. REGISTROS: '+ CONVERT(VARCHAR(20),@Contador)
PRINT '++++++++++++++++++++++++++++++++++++++++++++++++'
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.