Tema: Recursivo
Ver Mensaje Individual
Antiguo 02-may-2008, 16:04   #3 (permalink)
flaviovich
flaviovich está en el buen camino
 
Avatar de flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 1.298
Enviar un mensaje por ICQ a flaviovich Enviar un mensaje por MSN a flaviovich Enviar un mensaje por Skype™ a flaviovich
Re: Recursivo

No he probado este script, pero tu como el interesado lo haras:
Código:
CREATE FUNCTION dbo.sp_Seek4NestedRec
(
    @PI_IdActivoPadre INT
)
RETURNS TABLE
AS
DECLARE @TableVar TABLE(IdActivo INT, Activo VARCHAR(20), IdActivoPadre INT, Nivel INT)
IF EXISTS(SELECT 1 FROM Aviones WHERE IdActivoPadre = @PI_IdActivoPadre)
BEGIN
    SET @TableVar = dbo.sp_Seek4NestedRec(@PI_IdActivo)
END
RETURN SELECT * FROM Aviones WHERE IdActivoPadre = @PI_IdActivoPadre
    UNION @TableVar
--@@NESTLEVEL
GO
DECLARE @t_aviones TABLE(IdActivo INT, Activo VARCHAR(20), IdActivoPadre INT, Nivel INT)
SET @t_aviones = dbo.sp_Seek4NestedRec(@PI_IdActivo)
SELECT * FROM @t_aviones
__________________
No repitamos temas, usemos el Motor de busquedas
Plantea bien tu problema: Ayúdanos a ayudarte.
flaviovich está desconectado   Responder Citando