IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'[dbo].[sp_fco_cambio_salud]') 
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   DROP PROCEDURE dbo.sp_fco_cambio_salud
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE dbo.sp_fco_cambio_salud
(
    @CIA  	char(4),
    @TABLA      varchar(30),
    @COD_TRAB   char(10),
    @C11A  	char(4),
    @C13A  	char(1),
    @C13B  	char(1),
    @C13C  	char(1),
    @C13D  	char(1),
    @C13E  	char(1),
    @C13F  	char(1),
    @C13G  	char(1),
    @C13H  	char(1),
    @C13I  	char(1),
    @C13J  	char(1),
    @C14A       numeric(2,0),
    @C15A       numeric(9,0),
    @C17A       numeric(9,0),
    @C24A       numeric(9,0),
    @C25A  	varchar(10),
    @C25B       numeric(9,0),
    @C26A  	varchar(10),
    @C26B       numeric(9,0),
    @C27A       numeric(9,0)
)
/******************************************************************************************/
/*** Nombre:      sp_cambio_mf_salud                                                ***/
/*** Modulo:      ADAM V3. (Fiscal Colombiano)                                          ***/
/*** Descripcion: permite al usuario corregir las leves inconsistencias que             ***/
/***    	  ocasionalmente puedan presentarse en el reporte ALA Salud             ***/
/***              o en el medio magnético        					***/
/******************************************************************************************/
AS
DECLARE	@sql  VARCHAR(3000)

BEGIN
	SELECT @sql = "UPDATE " + @TABLA +
     	" SET" +
	" C11A='" + IsNull(@C11A,'C') + "'," +
     	" C13A='" + IsNull(@C13A,"") + "'," +
     	" C13B='" + IsNull(@C13B,"") + "'," +
     	" C13C='" + IsNull(@C13C,"") + "'," +
     	" C13D='" + IsNull(@C13D,"") + "'," +
     	" C13E='" + IsNull(@C13E,"") + "'," +
     	" C13F='" + IsNull(@C13F,"") + "'," +
     	" C13G='" + IsNull(@C13G,"") + "'," +
     	" C13H='" + IsNull(@C13H,"") + "'," +
     	" C13I='" + IsNull(@C13I,"") + "'," +
     	" C13J='" + IsNull(@C13J,"") + "'," +
        " C14A=" + IsNull(Convert(varchar,@C14A),'0') + "," +
        " C15A=" + IsNull(Convert(varchar,@C15A),'0') + "," +
        " C17A=" + IsNull(Convert(varchar,@C17A),'0') + "," +
        " C24A=" + IsNull(Convert(varchar,@C24A),'0') + "," +
     	" C25A='" + IsNull(@C25A,"") + "'," +
        " C25B=" + IsNull(Convert(varchar,@C25B),'0') + "," +
     	" C26A='" + IsNull(@C26A,"") + "'," +
        " C26B=" + IsNull(Convert(varchar,@C26B),'0') + "," +
        " C27A=" + IsNull(Convert(varchar,@C27A),'0') +
    	" WHERE CIA='" + @CIA + "'" +
    	" AND COD_TRAB='" + @COD_TRAB + "'"

	EXECUTE (@sql)

     	IF @@ERROR <> 0 RAISERROR 13000 "Error al Actualizar la Tabla"
END


GO
GRANT EXECUTE ON sp_fco_cambio_salud TO Public
GO