1
Tenh the following error in sql server:
Incorrect syntax near the keyword 'with'. If this statement is a common table Expression, an xmlnamespaces clause or a change tracking context clause, the Previous statement must be terminated with a semicolon
What can it be?
Follows the code:
declare @data date='2018-05-21'
With SomaDebCred AS (
SELECT ContabLancNumCtrl,
sum(case when ContabLancCtaCred is not null then ContabLancValor else 0
end) as soma_debito,
sum(case when ContabLancCtaDeb is not null then ContabLancValor else 0
end) as soma_credito
from CONTAB_LANCAMENTO
where ContabLancData = @data
and EmpCod='01.02'
group by ContabLancNumCtrl
),
NomeClientes AS (
SELECT A.ContabLancNumCtrl, A.soma_debito, A.soma_credito,
L.ContabLancValor, L.ContabLancHistComp,
L.ContabLancCtaCred, L.ContabLancCtaDeb
from SomaDebCred as A
inner join CONTAB_LANCAMENTO as L on L.ContabLancNumCtrl =
A.ContabLancNumCtrl
where A.soma_debito <> A.soma_credito
)
SELECT * FROM SomaDebCred
UNION ALL
SELECT * FROM NomeClientes
"Incorrect syntax near "com" keyword. If this statement is a common table expression, xmlnamespaces clause, or change control context clause, the previous statement must be completed with a semicolon"
– Rovann Linhalis
puts a point and comma of declaring @data date='2018-05-21'
– LLeon