-- EL SQLSERVER NO PERMITE ON DELETE SOBRE VARIAS COLUMNAS SOBRE UNA ASI Q SE CREA UN TRIGGER
CREATE TRIGGER DELETE_FORMATO_EXPO_NOVEDAD
   ON FORMATO_EXPO_NOVEDAD
   INSTEAD OF DELETE
AS 
BEGIN
 SET NOCOUNT ON;
 UPDATE PARAMETRO_NOVEDAD SET FORMATO_AUSENCIA = NULL WHERE FORMATO_AUSENCIA IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 UPDATE PARAMETRO_NOVEDAD SET FORMATO_CAMBIO_HORARIO = NULL WHERE FORMATO_AUSENCIA IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 UPDATE PARAMETRO_NOVEDAD SET FORMATO_AUTORIZACION = NULL WHERE FORMATO_AUSENCIA IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 UPDATE PARAMETRO_NOVEDAD SET FORMATO_FERIADO = NULL WHERE FORMATO_AUSENCIA IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 
 DELETE REPORTE_HORARIO WHERE FORMATO_AUSENCIA IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 DELETE REPORTE_HORARIO WHERE FORMATO_CAMBIO_HORARIO IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 DELETE REPORTE_HORARIO WHERE FORMATO_AUTORIZACION IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
 DELETE REPORTE_HORARIO WHERE FORMATO_FERIADO IN (SELECT ID_FORMATO_EXPO_NOVEDAD FROM DELETED)
END
GO