I have a trigger in the FRM_46 table that would be to replicate the data right after the insert or update for the FRM_31 table, however, it is not replicating, I already analyzed and did the tests, but I could not verify where the error is .
ALTER TRIGGER [dbo].[TGR_FORMULARIO_REPLICAÇÃO_NOVO_PROCESSO_ESTRATEGICO]
ON [dbo].[FRM_46]
AFTER UPDATE, INSERT
AS
BEGIN
DECLARE
@TarefaID INT,
@DataDoPerfilCliente nVARCHAR(15),
@PerfilCliente nVARCHAR(15),
@ContaID INT
BEGIN
SELECT @TarefaID = F.TarefaID,
@DataDoPerfilCliente = CONVERT(DATE,GETDATE(),103),
@ContaID = t.UsuIDCliente,
@PerfilCliente = f.C33
FROM inserted F
INNER JOIN Tarefa T on t.TarID = f.ChamadoID
IF @ContaID NOT IN (SELECT ContaID FROM FRM_31)
INSERT INTO FRM_31 (ContaID, C01, C02, C05) VALUES (@ContaID, @DataDoPerfilCliente, @PerfilCliente, @TarefaID);
IF @ContaID IN (SELECT ContaID FROM FRM_31)
UPDATE FRM_31 SET C01 = @DataDoPerfilCliente, C02 = @PerfilCliente, C05 = @TarefaID, C08 = null WHERE ContaID = @ContaID
END
END