Inguelberth Garcia
Quiz by , created more than 1 year ago

Quiz on Cursores, created by Inguelberth Garcia on 19/02/2014.

171
0
0
Inguelberth Garcia
Created by Inguelberth Garcia about 10 years ago
Close

Cursores

Question 1 of 10

1

/*
NumeroReal
1
2
3
4
5
*/
DECLARE @numero INT
DECLARE cCursor CURSOR
FOR SELECT numero FROM NumeroReal
OPEN cCursor
FETCH cCursor INTO @numero
WHILE (@@FETCH_STATUS=0)
BEGIN
PRINT @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
END

Select one of the following:

  • 1,3,5

  • 1,2,3,4,5

  • 1,4,5

  • 1,2,2,3

  • 1,2,4

  • 1,2,3

Explanation

Question 2 of 10

1

/*
NumeroDOS
2
4
6
*/
DECLARE @numero INT
DECLARE cCursor CURSOR
FOR SELECT numero FROM NumeroDOS
OPEN cCursor
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
WHILE (@@FETCH_STATUS=-1)
BEGIN
PRINT ':D'
FETCH cCursor INTO @numero
END
PRINT "TERMINO!"

Select one of the following:

  • :D
    TERMINO!

  • :D
    :D
    :D
    TERMINO!

  • :D
    TERMINO!
    :D
    TERMINO!
    :D
    TERMINO!

  • :D
    :D
    :D
    :D
    .......
    Infinito

Explanation

Question 3 of 10

1

/*
NumeroDOS
2
4
6
8
10
*/
DECLARE @numero INT, @interuptor BIT
DECLARE cCursor CURSOR
FOR SELECT numero FROM NumeroDOS
OPEN cCursor
SET @interuptor=0
WHILE (@@FETCH_STATUS=0 OR @interuptor=0)
BEGIN
SET @interuptor=1
PRINT @numero+1
FETCH cCursor INTO @numero
END

Select one of the following:

  • 1, 3, 5, 7, 9, 11

  • 3, 5, 7, 9, 11

  • 0, 3, 5, 7, 9, 11

  • 2,4,6,8,10

  • 21,41,61,81,101

Explanation

Question 4 of 10

1

/*
Abuelo
1 Andres
2 Ricardo
3 Eduardo

Padres
1 Juan abu:3
2 Luis abu:1
3 Marcos abu:2

Hijos
1 Marcos Papa:2
2 Andrea Papa:1
3 Lucas Papa:3
*/
DECLARE @nombre VARCHAR(255)
DECLARE cCursor CURSOR
FOR SELECT nombre FROM Padres INNER JOIN Abuelo ON Padre.idAbu=Abuelo.idAbu WHERE Abuelo.nombre='Andres'
OPEN cCursor
FETCH cCursor INTO @nombre
WHILE (@@FETCH_STATUS=0)
BEGIN
DECLARE @nombreN VARCHAR(255)
DECLARE cCursorN CURSOR
FOR SELECT nombre FROM Hijos INNER JOIN Padres ON Hijos.idPa=Padres.idPa WHERE Padres.nombre=@nombre
OPEN cCursorN
FETCH cCursorN INTO @nombreN
WHILE(@@FETCH_STATUS=0)
BEGIN
PRINT ' Hijo: '+@nombreN+' Y Nieto: '+@nombre
FETCH cCursorN INTO @nombreN
END
CLOSE cCursorN
DEALLOCATE cCursorN
FETCH cCursor INTO @nombre
END

Select one of the following:

  • Hijo: Marcos Y Nieto: Luis

  • Hijo: Luis Y Nieto: Marcos

  • Hijo: Andres Y Nieto: Luis

  • Hijo: Marcos Y Nieto: Marcos

Explanation

Question 5 of 10

1

/*
NUMEROS
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
*/
DECLARE @numero INT
DECLARE cCursor CURSOR
FOR SELECT numero FROM NUMEROS WHERE numero%2=0
OPEN cCursor
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
WHILE (@@FETCH_STATUS=0)
BEGIN
PRINT @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
END

Select one of the following:

  • 4,8,12,16,20

  • 2,4,6,8,10,12,14,16,18,20

  • 4,6,10,16,20

  • 2,4,8,10,16,20

  • 4,8,10,12,20

Explanation

Question 6 of 10

1

CREATE PROCEDURE ProcesarNumero @numero INT
AS
BEGIN
PRINT @numero%2=0
END
GO
EXEC ProcesarNumero 80

Select one of the following:

  • TRUE

  • FALSE

  • 0

  • 40

  • 2

Explanation

Question 7 of 10

1

1) DELETE
2) *
3) [NombreTabla]
4) WHERE [condicion]
5) [Campo]
6) FROM

Select one of the following:

  • 1,6,3,4

  • 1,2,6,3

  • 1,2,6,3,4

  • 1,3,6,3,5

  • 1,3,6,3,5,4

  • 1,3,4,5

Explanation

Question 8 of 10

1

/*
NUMEROS
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
*/
DECLARE @numero INT
DECLARE cCursor CURSOR
FOR SELECT numero FROM NUMEROS
OPEN cCursor
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
FETCH cCursor INTO @numero
PRINT @numero

Select one of the following:

  • 6

  • 7

  • 1,2,3,4,5,6

  • Error

  • 5

Explanation

Question 9 of 10

1

1)UPDATE
2)SET
3)FROM
4)WHERE [Condicion]
5)[Tabla]
6)[Campo]=[Valor]
7)VALUES

Select one of the following:

  • 1,5,2,6,4

  • 1,5,3,6,4

  • 1,5,7,6,4

  • 1,3,5,7,6,4

  • 1,3,5,6,4

Explanation

Question 10 of 10

1

/*
NUMEROS
1,2,3,4,5,6,7,8,9,10
DECIMALES
0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.0
*/
DECLARE @numero INT
DECLARE cCursor CURSOR
FOR SELECT numero FROM NUMEROS
OPEN cCursor
FETCH cCursor INTO @numero

DECLARE @numeroD NUMERIC(2,1)
DECLARE cCursorD CURSOR
FOR SELECT numero FROM DECIMALES
OPEN cCursorD
FETCH cCursorD INTO @numeroD

WHILE (@@FETCH_STATUS=0)
BEGIN
PRINT @numero+@numeroD
FETCH cCursor INTO @numero
FETCH cCursorD INTO @numeroD
FETCH cCursorD INTO @numeroD
FETCH cCursorD INTO @numeroD
END

Select one of the following:

  • 1.1
    2.4
    3.7

  • 1.3
    2.6

  • 1.1
    2.3
    3.6

  • 1.2
    2.6
    3.7

Explanation