Good afternoon!
Well, I have a great mission that is as follows. I have a script that I set up below that I need it to be executed only on the 1st of each month, respecting the two conditions that I put in the IF clause. I tried via trigger and job, however, without success. What is the best way?
DECLARE @Tarefa int
SET @Tarefa = (SELECT Tarid from Tarefa)
BEGIN
IF (SELECT TarStatus FROM Tarefa WHERE TarID = @Tarefa) = 9 --ESSE 9 SIGINIFCA QUANDO O STATUS DA TAREFA TIVER CONCLUIDA
and
(SELECT TarTipID FROM Tarefa WHERE TarID = @Tarefa) IN (select EstTarTipID from EstoqueTarefa where EstoqueID = 47) -- ESSA CONDICAO SIGNIFICA NAQUELE DETERMINADO CAMINHO
BEGIN
UPDATE EstoqueTarefa --ESSE UPDATE É PARA CHAMAR NESSA TABELA A INSERÇÃO DE NOVOS REGISTROS
SET Ativo = 1 --1 SIGNIFICA PARA ATIVAR A TABELA PARA GERAÇÃO DAS NOVAS TAREFAS
WHERE EstTarID = 570
END
END;
/*Produção Assistida Estratégico*/
SELECT T.TarID,
'DP-CustomerSu-47-970'
FROM Tarefa T
WHERE T.TarID = @Tarefa
AND T.TarStatus = 9