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

CREATE TRIGGER GRAVA_DTHRLANCSOL
ON SOLICITA
FOR INSERT
AS
BEGIN
   UPDATE SOLICITA
   SET DTHRLANCSOL = GETDATE()
   FROM INSERTED
   WHERE (ISNULL(SOLICITA.CDFILSOLI ,0) = ISNULL(INSERTED.CDFILSOLI ,0)) AND
         (ISNULL(SOLICITA.CDFILLANCA ,0) = ISNULL(INSERTED.CDFILLANCA ,0)) AND
         (ISNULL(SOLICITA.NRSOLICMP ,0) = ISNULL(INSERTED.NRSOLICMP ,0))
END;
GO
