IF COL_LENGTH('CRM_Cont_Motivos', 'Activo') IS NULL
BEGIN
	ALTER TABLE CRM_Cont_Motivos ADD Activo TINYINT
END
GO

IF COL_LENGTH('CRM_Cont_SubMotivos', 'Activo') IS NULL
BEGIN
	ALTER TABLE CRM_Cont_SubMotivos ADD Activo TINYINT
END
GO

IF COL_LENGTH('CRM_Cont_Objetos', 'Activo') IS NULL
BEGIN
	ALTER TABLE CRM_Cont_Objetos ADD Activo TINYINT
END
GO

IF COL_LENGTH('CRM_Cont_Motivos', 'Flag_Web') IS NULL
BEGIN
	ALTER TABLE CRM_Cont_Motivos ADD Flag_Web TINYINT
END
GO

IF COL_LENGTH('CRM_Cont_SubMotivos', 'Flag_Web') IS NULL
BEGIN
	ALTER TABLE CRM_Cont_SubMotivos ADD Flag_Web TINYINT
END
GO

IF COL_LENGTH('CRM_Cont_Objetos', 'Flag_Web') IS NULL
BEGIN
	ALTER TABLE CRM_Cont_Objetos ADD Flag_Web TINYINT
END
GO


UPDATE CRM_Cont_Motivos SET Activo = 1 WHERE Activo IS NULL AND Id_Motivo_Contacto <> 0
UPDATE CRM_Cont_SubMotivos SET Activo = 1 WHERE Activo IS NULL AND Id_Motivo_Contacto <> 0
UPDATE CRM_Cont_Objetos SET Activo = 1 WHERE Activo IS NULL AND Id_Motivo_Contacto <> 0


UPDATE CRM_Cont_Motivos SET Flag_Web = 1 WHERE Flag_Web IS NULL AND Id_Motivo_Contacto <> 0
UPDATE CRM_Cont_SubMotivos SET Flag_Web = 1 WHERE Flag_Web IS NULL AND Id_Motivo_Contacto <> 0
UPDATE CRM_Cont_Objetos SET Flag_Web = 1 WHERE Flag_Web IS NULL AND Id_Motivo_Contacto <> 0
