0
Good afternoon!
Guys, I have a big mission here. I have a script that I assembled below that I need it to be executed only on the 1st of each month respecting the two conditions I put in the IF clause. I tried via Rigger and Job, but 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
About "I need it to be executed only on the 1st of each month", schedule the job to run on the first day of each month. Under "Job Schedule Properties" set Day 1 of Every 1 Month.
– José Diz
Right, but @Josédiz, need to inform in this script that is some Rigger for example that this will only be enabled on day 1 or so even the job will understand?
– Renan Bessa
It cannot (and, unless mistaken on my part, nor can it) be trigger procedure (Trigger). Mount a job.
– José Diz