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

CREATE FUNCTION [dbo].[CF_SCA_ValidarMaster](@pId_Cliente INT)
RETURNS TINYINT
AS
BEGIN
DECLARE @Flag_Habilitado	TINYINT
DECLARE @Id_Cliente_Master	INT

SET @Flag_Habilitado	= 0
SET @Id_Cliente_Master	= 0

SET @Id_Cliente_Master = ISNULL((SELECT Id_Cliente FROM CD_Cli_Master WHERE Id_Cliente = @pId_Cliente), 0)

IF (@Id_Cliente_Master <> 0)
BEGIN
	/*Encontró el Id_Cliente en la tabla CD_Cli_Master*/
	SET @Flag_Habilitado = 1
END

RETURN ISNULL(@Flag_Habilitado, 0)

END