IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'dbo.CF_Seg_Menu_Leer_Padre') 
                   and type = 'FN')
BEGIN
    DROP FUNCTION dbo.CF_Seg_Menu_Leer_Padre
END
GO

CREATE FUNCTION dbo.CF_Seg_Menu_Leer_Padre (@pId_Modulo  INT,@pId_Menu INT)
RETURNS INT
AS
BEGIN
DECLARE @Id_Menu_Padre INT 

SELECT @Id_Menu_Padre = ME.Id_Menu_Padre
			FROM 	dbo.Seg_Menu_Mod ME
			WHERE ME.Id_Menu = @pId_Menu 
			AND ME.Id_Modulo = @pId_Modulo


RETURN @Id_Menu_Padre
END

