1
----Mostrar los caballos que no han participado en ninguna carrera --If OBJECT_ID('Cinactivo','P') IS NOT NULL --DROP PROCEDURE Cinactivo Create Procedure Cinactivo @IDC numeric(6) As Begin Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballos Open @CARRERAC Fetch next from @CARRERAC into @IDC While @@FETCH_STATUS=0 Begin If(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDC) IS NULL Select Nombre From Caballos Where ID_Caballo=@IDC Fetch Next from @CARRERAC into @IDC End Close @CARRERAC Deallocate @CARRERAC End Go EXEC Cinactivo @IDC = NULL

1C) Mostrar Los Caballos Que No Han Participado en Ninguna Carrera

  • Upload
    daaha2

  • View
    214

  • Download
    0

Embed Size (px)

DESCRIPTION

horses

Citation preview

Page 1: 1C) Mostrar Los Caballos Que No Han Participado en Ninguna Carrera

----Mostrar los caballos que no han participado en ninguna carrera

--If OBJECT_ID('Cinactivo','P') IS NOT NULL--DROP PROCEDURE Cinactivo

Create Procedure Cinactivo

@IDC numeric(6)AsBegin

Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from CaballosOpen @CARRERAC

Fetch next from @CARRERAC into @IDCWhile @@FETCH_STATUS=0

BeginIf(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDC) IS NULLSelect Nombre From Caballos Where ID_Caballo=@IDC

Fetch Next from @CARRERAC into @IDCEndClose @CARRERACDeallocate @CARRERAC

End

Go

EXEC Cinactivo@IDC = NULL