Error when i Execute procedure


#1

I am trying to execute a procedure, but the following error is appearing:
Here’s the procedure I’m using:

create proc ObterProxCaso_EnvioBoleto
as
begin

SELECT TOP 1
cana.IdCaso as IdCaso,
cna.CodigoCliente as CpfCliente,
canaac.NotaFiscal as NfGerada,
cna.NomeMailing

INTO #PROCESSAMENTO
FROM
CasosNA cna
INNER JOIN CasoAutomacaoNA cana on cana.idCaso = cna.Id
INNER JOIN CasoAutomacaoNA_AppCredito canaac on canaac.idCaso = cana.IdCaso
INNER JOIN CasoAutomacaoNA_EnvioBoleto canaeb on canaeb.idCaso = canaac.IdCaso
LEFT JOIN CasoAutomacaoNA_EnvioBoleto canaebSecundario ON
canaeb.IdCaso = canaebSecundario.IdCaso
AND canaebSecundario.IdStatus IN (1,2)
AND canaebSecundario.DataCriacao > canaeb.DataCriacao
WHERE
canaebSecundario.IdCaso IS NULL
AND
(
canaeb.IdStatus = 1
OR
(
canaeb.IdStatus = 2
AND
canaeb.DataAlteracao < DATEADD(MINUTE, -20, GETDATE())
)
)
end

Main.xaml (5.7 KB)