0
I made a condition that way:
If @dt_contabilizacao = @dt_operacional And Not Exists (Select 1 From tabela Where dt_mes_referencia = @mes_referencia)
But the check of dt is not necessary since if there is data of that month it no longer inserts, so I left so:
If Not Exists (Select 1 From tabela Where dt_mes_referencia = @mes_referencia)
Then a question arose, if I play this result in a variable that will contain '1' or be null, if it is null will insert, then I would make this condition in If, however I do not know if this is a way to improve the performance of the script or in it, Could you please take that question away?
Why not put the condition directly in command
INSERT
?– anonimo