IF EXISTS(SELECT * FROM sysobjects O, sysusers U
          WHERE
            o.name = 'DTULTATU_CFOPTEMP' and
            type = 'TR'                  and
            u.uid = o.uid                and
            u.name = USER)
   DROP TRIGGER DTULTATU_CFOPTEMP
GO

CREATE TRIGGER DTULTATU_CFOPTEMP
ON CFOPTEMP
FOR INSERT, UPDATE
AS
BEGIN
   IF NOT (0 = (SELECT COUNT(*) FROM INSERTED)) BEGIN
      UPDATE CFOPTEMP
      SET DTULTATUCFOPTMP = GETDATE()
      FROM INSERTED
      WHERE (ISNULL(CFOPTEMP.NRCFOPTEMP,0) = ISNULL(INSERTED.NRCFOPTEMP,0))   AND
            (ISNULL(CFOPTEMP.NRSEQUCFOP,0) = ISNULL(INSERTED.NRSEQUCFOP,0));
   END;
END;
GO

-- VERSAO --
EXEC ATUVEROBJ 'ATUALIZA_DADOS_DTPROCESSA','5.03.009';
GO
